Controlling an LED via the Mini-ABB & Basic Atom Pro

Heya all,

I recently bumped across this LED at SparkFun: sparkfun.com/commerce/produc … cts_id=105 It is a RGB LED and has 4 legs (sweeeeet). As far as I understand, you connect the cathode to gnd and the other 3 legs to a different pin on the Mini-ABB. If you have 5 of these LEDs then you would need to use 3 * 5 = 15, all 15 pins to control your LEDs.

So, I have a two part question for you guys.

  1. How would I be able to control just 1 of these LEDs? I can’t use low/high because high gives 5v which will kill an LED! Would I need to put resisters between the LED and the pin which I am connecting it to? How would I be able to control the voltage that is going to the LED? If I understand correctly, (red for example) you can give it anywhere between 1.9 and 2.5v and it will glow in different shades of red. How could I be able to control that? Is there like a digial pot (or analog pot. or some sort of pot that can be controlled via the board.) I can use? Connect it to the pin and the LED to the pot.

  2. How can I make it so that you dont need to use 15 pins to control 5 LEDs. Is there a way I can make each LED use up only 1 pin? How does this sound for example?
    Make a little PCB board with a micro on it which has the LEDs connected to it, and I can send a string to it to control the LED.
    e.g.
    SEROUT PIN, baudrate, “0”, “255”, “0”, “255”] 'LED ID, Red value, Green value, Blue value
    That example will make LED #0 turn pink (#FF00FF).

Then the micro or whatever I send it to will see that it must go to LED 0, and send the voltages it needs to. (0 will be the minimum voltage the leg can get and 255 will be max and numbers inbeen will be in between voltages.)

You guys understand what I am saying? Would it be possible to make something simple like that? Like a SSC-32 type of thing, but for LEDs?

Cheers,
robodude666

Not necessarily true.
Depending on the LED model, it might be perfectly fine to supply it with 5V.
The real enemy here is current.
Thus, one puts a “current-limiting resistor” in series with the LED to limit the amount of current that it recieves.

Well, there are indeed some options like that, but you can do away with them.
You actually have all the hardware you need built right into your microcontroller.
By PWMing the LED, you can control the average amount of voltage going to it.
You control this by adjusting the duty cycle.
A duty cycle of 50% will mean an average voltage of 2.5V from that I/O pin.
The faster the PWM frequency, the smoother that “average voltage” will be.

It sounds like your idea would work, but it’s quite costly if you’re using BASIC micros!

For simple I/O expansion, you can always get a shift register.
There’s many different ones with many different interfaces.
From the sound of it, you’ll want to look for a serial shift register.
There’s even special shift registers made expressedly for LED driving.

An interesting tidbit:
The SSC-32’s microcontroller is connected to four of these, each of which provides 8 extra I/Os, which is where the 32 servos comes from (8 x 4).

Almost forgot…

When connecting your LEDs, it’s best to connect one end of the LED/resistor combo to the micro and the other end to 5V+.
This is because micros typically can sink current more easily than sourcing it.

So, to turn on the LED, you’d set that pin to a logic “0” (a.k.a. “low”).
Yes, it indeed seems backwards, but it’s a nice practice to get into.

I see, would one of these work?
standardics.philips.com/prod … f4894b.pdf
There is a nice little picture on the bottom on how to connect it. How would I control it via the Basic Atom? What would I I2COUT to it though?

That bugger is a 12-bit I2C LED driver.
It’s probably a better idea to go with the 8-bit version, since byte-length characters are the usual standard.
From looking at the datasheet, controlling it seems pretty straight foreward.
First the micro’s address followed by the write bit.
Then the micro’s internal settings.

After than, you send two bytes for each LED output.
The first byte determines LED brightness and PWM frequency.
The second byte sets PWM and the duty cycle.