Go Down

Topic: Controlling different leds over serial (Read 1 time) previous topic - next topic

AllenI


Why are you reluctant to say how you have wired things up? What value resistors are you using?
Is it because you are hiding something you don't want people to know?


well I do want alot of leds for my display like I stated in the first post but Im also trying to hack this big santa display. I think Im moving too fast, so I just want to get the code down and functioning on a single 3mm led. But these 3mm will be replaced with high powered leds(not there yet though) Then I'll figure out how to expand the circuit from that with more leds with either transistors or shift registers and possibly BT. I found a tutorial on Adafruit similiar to what Im looking to do: http://www.ladyada.net/products/rgbledstrip/  but the strips would be replaced with a high powered led. Im using 100 ohm resistors right now. How can I draw out my circuit with the arduino and breadboard like in the tutorial?

Grumpy_Mike

Quote
Im using 100 ohm resistors right now.

A bit low but should be ok.

You need to add code to drive those.

Quote
Then I'll figure out how to expand the circuit from that with more leds

Fine that is a project in itself with diffrent ways to go however you might want to look at this:-
ShiftPWM library
http://www.elcojacobs.com/shiftpwm/

Quote
How can I draw out my circuit with the arduino and breadboard like in the tutorial?


fritzing.org/

But please post a real schematic.

AllenI


Quote
Should I have it setup like this: if(mySerial.available() >3)...making sure there's 4bytes in the buffer? Or is that no good either?

That's better, but still not perfect. I'll try to explain why. Reading and acting on 4 values read from the serial port is fine, up to a point. Suppose that the serial buffer contains 'L', 120, 34, 95, 'R', 14, 126, 240. Now, if you test that there are 4 or more bytes, and read the first 4 bytes, you have all the data needed to control one LED, and you know which one to ...


hmm, I see what your saying, thank you for the detailed explanation. Will flushing the buffer and changing the baud rate help if I choose to send bytes?

billroy

I'm sure you'll get your C program sorted out eventually.

Meanwhile, if you just want to bench test the LEDs, you can install Bitlash (http://bitlash.net) and define little test functions like this to debug your circuit:

Code: [Select]

// Bitlash functions to independently control two RGB LEDs on pins 3/5/6 and 9/10/11
function setup { pinmode(3,1); pinmode(5,1); pinmode(6,1); pinmode(9,1); pinmode(10,1); pinmode(11,1); }
function setleft  { a3=arg(1); a4=arg(2); a5=arg(3); }
function setright { a9=arg(1); a10=arg(2); a11=arg(3); }


Then, in the serial monitor, you can tell bitlash to set the left one red and the right one yellow:

Code: [Select]

> setleft(255,0,0); setright(0,255,255);


Without writing any parsing code.

-br

PaulS

Quote
Will flushing the buffer and changing the baud rate help if I choose to send bytes?

No. Flushing the buffer, in the pre-1.0 sense of dumping random amounts of unread data, hardly seems like a good idea. Flushing the buffer, in the post-1.0 sense of blocking until the outgoing buffer is empty, hardly seems useful.

Changing the baud rate won't affect noise, poor connections, etc. that are the general cause of serial data corruption/loss.

AllenI

I've been reading up on packets and their use, but I havent been able to find a good source or set of instructions on how to create one. If I use your example from before PaulS, the packet I wanna create should look like this: <R, redvalue, greenvalue, bluevalue>

So I have to establish '<' is the start of the packet, ???. I read something in my search I should try to make each step a function for debugging purposes later on?

Grumpy_Mike

To send a '<' simply use
Code: [Select]
Serial.write('<');

Go Up