RGB LED Light bar project. Need some help with basic coding.
Kd7lax
Posts: 42
Hello All,
So one of my newest projects is some RGB led light bars. This project is for lighting effect inside my computer case.
For now I have been playing around with one RGB LED to get the hang of coding for it, eventually I would like to have some kind of random color generator that could be activated by pressing a button.
I have been using code from some tutorials for the SX and BS2 such as (all the testing is being done on my bs2 OEM)
Just fading in and out solid colors Red, Green and Blue. How would I vary these colors?
I have done other colors by using:
But when doing this the light gets all flashy... not sure why?
So any way I guess my question is: Can I vary the colors just using a BS2 or a SX? and if so how? Or if I can't what other kind of hardware do I need?
Sorry if this is kind of a noob question, Its been a while since I have played around with RGB stuff.
Thank you in advanced for the replies.
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio
So one of my newest projects is some RGB led light bars. This project is for lighting effect inside my computer case.
For now I have been playing around with one RGB LED to get the hang of coding for it, eventually I would like to have some kind of random color generator that could be activated by pressing a button.
I have been using code from some tutorials for the SX and BS2 such as (all the testing is being done on my bs2 OEM)
Start: DO FOR duty = 0 TO 254 PWM Blue, duty, 50 NEXT FOR duty =254 TO 0 PWM Blue, duty, 50 ...etc
Just fading in and out solid colors Red, Green and Blue. How would I vary these colors?
I have done other colors by using:
NEXT FOR duty = 0 TO 254 PWM Red, duty, 30 PWM Blue, duty, 30 NEXT FOR duty =254 TO 0 PWM Red, duty, 30 PWM Blue, duty, 30 NEXT
But when doing this the light gets all flashy... not sure why?
So any way I guess my question is: Can I vary the colors just using a BS2 or a SX? and if so how? Or if I can't what other kind of hardware do I need?
Sorry if this is kind of a noob question, Its been a while since I have played around with RGB stuff.
Thank you in advanced for the replies.
-Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit my website @ www.kd7lax.com- Devoted to ham radio
Comments
So, I'd go with:
The PWM Red time + PWM Blue time = 30ms.
When you're ready·to go R-G-B:
I've done this differently, but I didn't want to·steer you away from your chosen PWM command paradigm.
Post Edit -- I wouldn't be using the R-C circuit, just the raw PWM output.
Post Edited (PJ Allen) : 12/18/2008 8:08:03 PM GMT