Main‎ > ‎electronics‎ > ‎

RGB_LED_x_3

28/04/2009

I've finished converting the code, it's now available here 3RGB. I haven't worked out how to draw schematics easily yet so the basic set up is 3 RGB leds plugged into a atmega16,  PORTA PIN 0, 1 and 2, and PORTC PIN0, 1, 2,  3, 4 and 5. There are also 2 status LEDs, i use red and green.

here is a close up pic of the setup:


27/04/2009

So I'm working now to make this a interrupt driven code. This means that my program actually manipulates an array of  9 "on/off" values and while it is running, an interrupt routine draws the array onto the actual LEDs. This separates the drawing from the manipulating which will become necessary when I start wanting to multiplex and replacing "on/off" values, with serial data for luminosity for the LED Drivers that I have.

I've pretty much converted the code already, all i need to do is convert the patterns I have to the new "format".



---START---
I'm working on the code to control 3 RGB LEDs. In this current incarnation, all the LEDs are plugged directly into output pins on the controller and only have on and off states, meaning each LED only displays 7 colors.  I realize this is an inefficient and not scalable approach, but I'm only starting to learn about multiplexing and PWM and all that, so this is where I'm up to so far. My intention is to next figure out how to do PWM, and then learn multiplexing, so I can make a 3x3 grid of RGB LEDs, and after that, possibly a cube of 3x3x3. If I'm not sick of it by then, the 8x8x8 RGB cubes look amazing, but i'm not sure i'll get that far!



The top photo shows the low tech "hood" I made out of baking paper to diffuse the LEDs. The LEDs are the 10mm "diffuse" type, I'd never seen them before and spent a while trying to decide if I should get them or just get the regular 5mm ones. The bigger ones were more expensive obviously, but not by a lot, and i'm glad I got them, they're super cool. Even though they're diffuse, they're still quite bright on their own, the hood does a surprisingly good job of "displaying" the light.

Basically, i have preserved the basic layout of the 4x4x4 cube project, I actually intended to make 2 of them, however, instead of the cube matrix I've plugged in 3 RGB LEDs into the controller. They're common anode so the anodes are just connected to +5v and the individual cathodes are connected to  PORTA pins 0, 1 and 2, PORTC pins 0, 1 and 2, and PORTC pins 3, 4 and 5. The code is very dirty, each color is represented by a 3 bit number, because it is common anode, 0 actually means on and 1 is off, which took a while to get used to! The colors are then sent by the code to each of the 3 port positions representing the 3 LEDs. The LED on PORTA  was easy to address,  but since there are 2 LEDs on PORTC, I actually had to work out how to bit shift the color bits by 3 positions and then add it to the color bits of the 2nd LED to light up both LEDs. 

It looks like this:
PORTA = (R);
PORTC = (R << 3)  + (R); 

Wow looks simple huh? But if you aren't a programmer like me, every basic step is a learning experience! :) I'm really happy with the result and still looking forward to learning more. If anyone is a gun at c and wants to give me a hand, i'm happy to share ideas and resources. 

 

You can find my current code and makefile right here, however, it should include a disclaimer, because I'm not a programmer, the code is mostly "borrowed" from various other projects I've found around on the net, and what is not borrowed is very quick and dirty. Most of it inspired by the code available with the 4x4x4 cube project I completed from http://www.instructables.com/id/LED-Cube-4x4x4/ .


Under the hood:



Comments