Help with RGB LEDs

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
Post Reply
User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Help with RGB LEDs

Post by Roller Toaster » Thu Jun 15, 2017 12:03 am

I have recently purchased a bunch of 4-pin RGB LEDs, and I was wondering if I could use only a single one of them to represent the various statuses of the pi. I am using the SAIO board with a Pi 3 and my understanding is that I can just connect the LED pins to the existing LED pads to get it to display each color, but how can I customize the colors?

I had several uses for this:
I want it to blink yellow while roms are transferring from a computer.
Otherwise, it would display power and charge status, with orange being the low power indicator and blue being the good power indicator. Green would represent charging. Plus, with the ability to assign any colors to events I could even use them if there are issues with overheating or problems on startup.

My current idea is to fit some sort of programmable potentiometer in with the LED, but perhaps there is an easier way that doesn't require additional hardware and instead depends on me just designating RGB inputs for certain conditions.

User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Re: Help with RGB LEDs

Post by Roller Toaster » Fri Jun 16, 2017 2:07 pm

I'm gonna shamelessly self-bump and also add that I didn't know about PWM until a few minutes ago. Would it be possible to, in code, change the LED status of a 4-pin LED connected to the existing LED pads? Also, what resistors would I need (if any)?

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Help with RGB LEDs

Post by Quatrerwin » Fri Jun 16, 2017 2:38 pm

Sota did a build with an RGB LED. The concept should be similar to yours. http://www.sudomod.com/forum/viewtopic. ... iny#p18098

User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Re: Help with RGB LEDs

Post by Roller Toaster » Mon Jun 19, 2017 12:20 am

Quatrerwin wrote:
Fri Jun 16, 2017 2:38 pm
Sota did a build with an RGB LED. The concept should be similar to yours. http://www.sudomod.com/forum/viewtopic. ... iny#p18098
That's pretty close to what I'm looking for but I don't know anything about the ATtiny and Sota doesn't go into much detail on his build. At this point, I don't know if I should purchase an ATtiny since there are many different versions and I'm not sure which I need.

Can anyone on here point me towards a good crash course on using Arduino code on a programmable microchip for this purpose? Keep in mind I'm just a dummy who's only taken one electrical engineering course in basic logic circuits.

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Help with RGB LEDs

Post by Quatrerwin » Mon Jun 19, 2017 7:05 am

He actually uses an ATMega (I think an ATMega328P). He uses it because the way the powerboost works. If he would have used an ATTiny, he would only have gotten two statuses to work. I'm not sure how your board operates (if it needs the ATMega or if an ATTiny will do).

As for the programmable aspect, this is pretty similar to what you would want: http://www.electroschematics.com/8964/t ... n-arduino/. You have x amounts statuses and inputs. You will want to use the PWM pins for output, otherwise your color options will be severely limited. Adafruit has some sample code here: https://learn.adafruit.com/adafruit-ard ... ino-sketch. Likely you will want to combine the both code samples to get it working. There are many ways of getting the code to work. I haven't really written any code for an arduino yet, but I am a software developer. You can use a loop like the example does to check the inputs to decide which status you want to show (and if any status has precedent over any other of more than one status is active). You should also be able to do something event driven, but this is a little more advanced.

User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Re: Help with RGB LEDs

Post by Roller Toaster » Mon Jun 19, 2017 10:58 pm

Quatrerwin wrote:
Mon Jun 19, 2017 7:05 am
He actually uses an ATMega (I think an ATMega328P). He uses it because the way the powerboost works. If he would have used an ATTiny, he would only have gotten two statuses to work. I'm not sure how your board operates (if it needs the ATMega or if an ATTiny will do).
I thought it was the ATtiny2313? Either way, I'm probably going to have to ask Kite since I wouldn't know where to begin attaching that to the SAIO board. I also have no idea how I'm going to hook this up to my computer to program it.

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Help with RGB LEDs

Post by Quatrerwin » Tue Jun 20, 2017 10:48 am

Sota mentions it here: http://www.sudomod.com/forum/viewtopic. ... =20#p18125. He also has a wiring diagram here: http://www.sudomod.com/forum/viewtopic. ... =20#p18133. I imagine it will be similar with Kite's board except you'll use the existing LED pads/holes on the SAIO as inputs instead of the LED pads on the powerboost.

As for programming it, there are several ways of doing it. I'm using a fairly cheap AVR programmer I found on eBay: http://www.ebay.com/itm/5V-AVR-Programm ... 1489740923.

User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Re: Help with RGB LEDs

Post by Roller Toaster » Tue Jun 20, 2017 4:48 pm

I see. Earlier in his build he mentions the ATtiny2313, but his wiring diagram is helpful. Unfortunately, it connects to the powerboost and only supports 3 states. I want a fourth state, which is for it to blink yellow when rom transfer/update is in progress. I will probably post in the SAIO support thread later to ask about that.

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Help with RGB LEDs

Post by Quatrerwin » Tue Jun 20, 2017 10:15 pm

You can do that if the SAIO outputs that state in one form or another. You just need a chip that supports the number of inputs that you need while having enough outputs to drive the LED.

User avatar
Roller Toaster
Posts: 59
Joined: Thu Jun 01, 2017 7:15 pm
Location: McLean, VA
Has thanked: 45 times
Been thanked: 20 times

Re: Help with RGB LEDs

Post by Roller Toaster » Fri Jun 23, 2017 10:30 pm

I've received info from Kite that seems to indicate that I can just use the board rather than getting an extra chip for this. If anyone else is curious, here's what he wrote:
kite wrote:
Fri Jun 23, 2017 2:46 am
You'll want to do this on the arduino, look at the PDF guide and it should show the pin usage on arduino.. i need to update it and put on wiki for the 0.6C version as it's slightly different.. but basically you can use the SPI, TX, RX, A0, A1 pins to do what you need.. getting the 'is charging 'status is going to be a bit harder you'll need to probe around for those signals near the charging LED.. as for wlan activity you'd need something running on the Pi to detect that and send the command data to the Arduino to then set your LED .. i can put those suggestions on to the battery monitor as that will be much easier to do :)
Thanks for all the help, although now I have to educate myself on Arduino before my LEDs arrive :|

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest