Wednesday, October 18, 2006

Sparkfun's Triple Output LED RBG on the BOE-bot

I bought a few doo-dads from sparkfun.com a while back and finally got around to playing with the triple output LED. It works like any other LED only it has four leads instead of two. I always forget what is the anode and what is the cathode, but regardless it has one lead that goes to ground and the others go to the output leads from the BOE-bot, with a 470 Ohm resistor to drop the voltage down to a level that won't fry the LED. Please note that the red portion of the LED had a lower max voltage than the green or blue. I ignored this and used the same LED circuit I had used in a previous BOE-Bot LED excersize. It hasn't killed the LED yet so I think it will live. Anyway I wrote a little code using pulse width modulation to fade from one color to another. It works pretty well. I'll see if I can post the video I took of it working. See the code below:

'RGB LED Changer

' {$STAMP BS2}
' {$PBASIC 2.5}

counter VAR Word
DO
FOR counter = 1 TO 100
PULSOUT 9, 1000 - (10 * counter)
PULSOUT 11, 10 * counter
PAUSE 5
NEXT
FOR counter = 101 TO 200
PULSOUT 11, 1000 - (10 * (counter - 100))
PAUSE 5
PULSOUT 10, 10 * (counter - 100)
PAUSE 5
NEXT
FOR counter = 201 TO 300
PULSOUT 10, 1000 - (10 * (counter - 200))
PAUSE 5
PULSOUT 9, (10 * (counter -200))
PAUSE 5
NEXT

LOOP

4 comments:

Lee said...

Hey, what else have you done with them?

Anonymous said...

Yeah, ditto!

Anonymous said...

Hey, Lay off him, he is obviously very busy!

Pete said...

Lee, are all of these comments yours? because they all sound like you. I actually did some work on the 16F628A this weekend. I wired it up and loaded a "blink" program to it but I haven't added any LED circuits to it yet so I'm not positive that it works. I'll take some pics tonight and blog it this week :)