Controlling leds via serial.

Do you have a technical question that doesn't really fit a specific console? Want some general info on electronics, hacking, making cookies, etc? Here's the place to ask! Go nuts.

Moderator: Moderators

Post Reply
Felino
Posts: 1010
Joined: Thu Jan 18, 2007 12:51 am
Location: Australia.

Controlling leds via serial.

Post by Felino »

Kays, i have a nice juicy 3W RGB led here. I was originally goign to use heaps of smaller leds (as mentioned before) but decided to use one luxeon led.

Now to controll these via a serial port, i will need some hardware right (unless the serial port can handle 3 x 350 :P )now, i am going to use a 5v power pack to drive them.

I wanted to pwm them off an old laptop in the corner of my room, as to make a simple rbg light up my wall, is it possibe to get an app to do this randomly?

Can i also, one last thing, get the program to display cretain colours when i get an email, like darker shades of blue for more emails or somthing?

-The Fel.

EDIT: Although it doesn;t look like it, this is lighting my entire room up, with the blue.
Image
Ignore the tablecloth, it had to look neat. :D
Charlie wrote:I always wanted to try wall flips, but I'm too attached to my neck.
Image
Life of Brian
Moderator
Posts: 2867
Joined: Wed Aug 03, 2005 5:55 pm
Location: Oklahoma
Contact:

Post by Life of Brian »

Well, you could program a microcontroller and run the whole thing off of batteries. That way you wouldn't have to leave a computer attached.
dragonhead wrote:sweet. ive spent a third of my life on benheck!
Image
Felino
Posts: 1010
Joined: Thu Jan 18, 2007 12:51 am
Location: Australia.

Post by Felino »

Ah, i have done that in the past, but i thought i might go adventurous. I have this laptop runnign other stuff all the time.

-Fel
Charlie wrote:I always wanted to try wall flips, but I'm too attached to my neck.
Image
timmeh87
Senior Member
Posts: 3047
Joined: Mon Nov 14, 2005 10:19 pm
Location: Ontario, Canada

Post by timmeh87 »

ok so im going to try and think something out here...

use 8 bit latching shift registers (sn74hc595) and PNP transistors (because by default the serial levels are inverted)

you will have to control the shift clk and latch clk with something. for the latch clk (ie the signal that displays the contents of the shift register) you could use the control lines of the serial port, like DTR and CTS. I dont remember offhand which ones are outputs, but two of them are so use those.

the shift clk would be harder, as standard serial ports dont provide a clock signal, but shift registers require each bit to be clocked in as the value is held on the SDATA pin.

basically you would have to use another one of the control lines for the shift clock, but AFAIK, you cant change them mid-byte, so bear with me here as i invent the ultimate ghetto solution:

if you use a good enough shift register, the time between stable data and the rising edge of SCLK (ie shifting trigger) is on the order of 25ns. also, a simple logic inverter has a gate delay of about 10ns. so get an octal inverter IC, and hook them all in series, so that the input signal is unchanged but has a delay of 80ns.

in your software, you would be writing bytes to the serial port. but, since I am assuming you can only change the state of the control lines between bytes, and you need to do so to clock a single bit in, you will only be able to shift in one bit for every whole byte you send. the sequence would go like this

- bring SCLK low
- as much time as you want
- bring SCLK high
- less than 55ns delay
- send either 0x00 or 0xFF (1 or 0) over the serial port.

alternatively, for the delay you could use a resistor and capacitor to make a simple low-pass filter that will turn the rising edge of the control line into a gentle slope. with the right values, and knowledge of the minimum voltage to detect a rising edge, you should be able to custom tailor any delay.

ok so this is a very roundabout way of doing it. here is an easier and MUCH more effective solution:

- Use a dsPic that has a whole whack of PWM drivers already built in
- Connect it to your PC's serial port
- Use the PIC as a slave device to your PC, where the pc basically sends the color (or multiple pixels if you want) and the PIC does all the rest of the work.

guess which solution I prefer.
Image

"Linux is only free if your time is worthless"
Felino
Posts: 1010
Joined: Thu Jan 18, 2007 12:51 am
Location: Australia.

Post by Felino »

so, if i used a pic, then just send the signals over the serial line? i suppose that would be easier from a software/hardware look. i might go that way.

i could just send the r/g/b values, then let the pic work out the timing, sounds great :D

thanks
Charlie wrote:I always wanted to try wall flips, but I'm too attached to my neck.
Image
Mario
Posts: 1383
Joined: Mon Mar 05, 2007 7:20 pm
Location: Sunny California

Post by Mario »

If the laptop is running Windows 95/98, you can easily control the parallel port in Microsoft Quick Basic.
I've been working on a little project, and what I have so far is 8 LEDs on a breadboard, hooked up to the parallel port on my laptop. I just run the QBasic program I wrote, and I can easily control the LEDs from my computer. If you want, I can give you the code, or more information.

The reason you need Windows 95/98 is because in newer operating systems, you can't control the parallel port with QBasic.
Image
Post Reply