Hi guys, I'm no stranger to circuit building, but it's been mainly high-voltage stuff up 'til now.
Bought my first uC on a whim the other day (Arduino Uno), and this project was my first time doing any coding what-so-ever, aside from a few quick practice sketches. I'm pretty much done; just looking for a few knowledgeable opinions/suggestions/constructive criticisms. Sorry if the code's messy or hard to read but hey I am looking for advice. I also have a sneaking suspicion I could buy an IC that does the same job as this, and if you know of one don't ruin it for me lol.
Anyway, the code is written to control one of about 20 really nice Kingbright 6 pin RGB leds that have been sitting in my parts bin for years. I've been trying to come up with a cool use for them for some time now.
The code lets you mix the 3 colors in any proportion with a joystick to create any color in the spectrum. It also has a neat curving feature that ensures one of the colors is always maxed out, making much better use of the full power of these LEDs (and damn are they bright)!
The driver board I built is nothing fancy; just a regulator, filter cap, 9V battery connector, series resistors, three 2n2222 transistors, and the joystick. If you want the schematic let me know and I'll draw one up haha. I built the driver board because the individual colors would draw current on the borderline of what the Arduino is rated to source (30mA green/blue, 50mA red), and because of the odd shape of the LED package. However, it should work fine with a setup as simple as 3 standard LEDs wired right to the outputs of the board and stuffed in a ping pong ball.
If you choose to go this route and also don't have a joystick (or can't be bothered to set one up), I have some additional code that uses sine/cosine to simulate the joystick being slowly rotated around the edge. This is also better for a display use as it requires no human control.
Now that that's all out of the way, I do have one question. This is more of a matter of personal preference, but the documentation says analogWrite PWM uses a frequency of about 490 Hz. Is there an easy way to kick this up to about 1 kHz without having to figure out a way to code it in manually?
Thanks guys,
Shaun
attached:
-mixer code
-automated mixer code
-driver pic (led on top-left)
rgbmixer_shaun_sless.ino (4.18 KB)
rgbmixer_auto_shaun_sless.ino (4.65 KB)