Help with programming an LED knight-rider scanner!

Hey there everyone, this is my first post. I signed up for these forums because after hours of going about the internet, i was royally confused with this. Im pretty new to arduinos, or any type of electronics for that matter (mechanics were more my thing). I am building an LED knight rider scanner for the hood scoop of my truck, just for fun. Im going to have a number of LEDs inside it, to scan back and forth when the arduino receives power. If i was just going to use 13 or less LEDs, i would just have the negative all connected to the ground, and simply have one LED hooked up to each pin. i plan to use at least 18 LEDs though. After searching through google i started reading about charliplexing, and i think that is how i will be able to get this done! So far, not having too much luck though. The LEDs do cycle in order! But... other LEDs come on too :confused: if anyone can help me solve this i will be very grateful!

What i have right now:
-Arduino Uno, with 6 LEDS (with build in resistors)
the LEDs are connected like this:
LED# | 1 | 2 | 3 | 4 | 5 | 6
pin13 | + | - | | | + | -
pin12 | - | + | + | - | |
pin11 | | | - | + | - | +

this is the code i have to far

void setup()  
{    
pinMode(13, OUTPUT);       
pinMode(12, OUTPUT);    
pinMode(11, OUTPUT);        
}    
void loop()  
{      
digitalWrite(13, HIGH); 
digitalWrite(12, LOW);

delay(1000); 


digitalWrite(13, LOW);
digitalWrite(12, HIGH);   

delay(1000);   

digitalWrite(12, HIGH); 
digitalWrite(11, LOW);

delay(1000); 


digitalWrite(12, LOW);
digitalWrite(11, HIGH);   

delay(1000); 

digitalWrite(13, HIGH); 
digitalWrite(11, LOW);

delay(1000); 


digitalWrite(13, LOW);
digitalWrite(11, HIGH);   

delay(1000); 


}

Any help would be greatly appreciated! im having a blast playing around with the Arduino Uno and hope to be able to get this project running soon!

-Zac

I've considered this project for about 20 years now, my car has a fake hood scoop that would be perfect for it. For some reason, i've never actually done it, I even have some boards that already do the circuit, all i would have to do is hook it up to new LEDs, and power it. Maybe one day I will do it...

Charlieplexing is a great way to control a lot of LEDs, but using LEDs with built in resistors might be an issue, since you will be always using 2 resitors anytime you try to light an LED. If you can control the resistor size, you can calculate your resistor size, and then use 2 resistors that are 1/2 the correct value, to end up with the right value when charlieplexed.

The code for turning on an LED will always be one high, and one low. both high, or both low should not light anything, and reversing polarity will change which LED is lit.

You can also run 18 LEDs off the arduino, but you would need to run them at 10ma, instead of 20, which would be a bit dimmer. There are other options too, but it gets more complicated.

If properly wired, you should be able to control 20 LEDs from 5 pins with charlieplexing. You could also multiplex 25 with 10 pins easily enough.

Thanks for the quick reply! ive been wanting to do this forever, and since im stuck at home sick, i thought id give it a shot! i updated the original post with more info!

Get a TLC5940 LED controller chip and use the basic example program (which just happens to be a "Larson Scanner" - which is what they're called).

The chip makes sure all your LEDs are running at optimal power and protects your Arduino from the stress of charlieplexing.

Hippynerd:
Charlieplexing is a great way to control a lot of LEDs, but using LEDs with built in resistors might be an issue, since you will be always using 2 resitors anytime you try to light an LED.

Not if the resistors are in parallel - which they will be if they're "built in".

fungus:
Get a TLC5940 LED controller chip and use the basic example program (which just happens to be a "Larson Scanner" - which is what they're called).

The chip makes sure all your LEDs are running at optimal power and protects your Arduino from the stress of charlieplexing.

I will look into one of the chips! I also want to learn how to do it with just the LEDs for practice too.

fungus:

Hippynerd:
Charlieplexing is a great way to control a lot of LEDs, but using LEDs with built in resistors might be an issue, since you will be always using 2 resitors anytime you try to light an LED.

Not if the resistors are in parallel - which they will be if they're "built in".

Do you suggest i try something else then?

fungus:

Hippynerd:
Charlieplexing is a great way to control a lot of LEDs, but using LEDs with built in resistors might be an issue, since you will be always using 2 resitors anytime you try to light an LED.

Not if the resistors are in parallel - which they will be if they're "built in".

Thats curious, why would you build a resistor in parallel with the LED?

If you use the TLC chip, you will only be able to run 16 per chip, and you will also need some other parts (a couple resistors and a cap per chip). If you want to run 18 LEDs, then you will need 2 TLCs, 4 resistors, and 2 or maybe 4 caps. You will also probably want to use some kind of circuit board to hold all these parts.

its a lot of extra stuff to learn and build, but you get the benefit of PWM, so thats kinda cool, if you want that feature.

another way to do it is to serialize each LED with its own chip. It uses a lot of parts, but its easy to expand/contract the number of LEDS.

Multiplexing uses no extra parts, but it is more complex wiring, its sort of a trade off.

Zakc:
I will look into one of the chips! I also want to learn how to do it with just the LEDs for practice too.

Be my guest...

PS: A good Larson Scanner fades the LEDs out when the scan passes them. Charlieplexing makes fading difficult.

Zakc:
Do you suggest i try something else then?

No, playing with LEDs is always a good thing.

You might want to spend some time reading up on C++ programming, too. Learn about loops and stuff.

Hippynerd:
Thats curious, why would you build a resistor in parallel with the LED?

fungus:

Hippynerd:
Thats curious, why would you build a resistor in parallel with the LED?

LMGTFY - Let Me Google That For You

oh i didnt build it, i just bought a bundle of them from Radio shack, thinking it would make my life a bit easier!

Hey there everyone, this is my first post

Did you read this post at the top of this section?

Any good reason why not?

@fungus, why in parallel?

AWOL:
@fungus, why in parallel?

I never said 'parallel', that was Hippynerd.

AWOL:

Hey there everyone, this is my first post

Did you read this post at the top of this section?

Any good reason why not?

I did read the first post? but i re-read it to see why you asked that, and saw that i forgot to use the code tag in my original post, sorry about that!

fungus:

AWOL:
@fungus, why in parallel?

I never said 'parallel', that was Hippynerd.

I was quoting you when I had said that. You suggested that the resistors will be in parallel, you put the word will in italics to emphasize that correct?

Also, the google search didnt really answer my question. Is it too difficult to type a whole sentence to explain why?

Hippynerd:
I was quoting you when I had said that. You suggested that the resistors will be in parallel, you put the word will in italics to emphasize that correct?

Also, the google search didnt really answer my question. Is it too difficult to type a whole sentence to explain why?

How can you get two resistors in series when they're inside the LEDs and the LEDs are in parallel?

fungus:

Hippynerd:
I was quoting you when I had said that. You suggested that the resistors will be in parallel, you put the word will in italics to emphasize that correct?

Also, the google search didnt really answer my question. Is it too difficult to type a whole sentence to explain why?

How can you get two resistors in series when they're inside the LEDs and the LEDs are in parallel?

Hippynerd:

fungus:
How can you get two resistors in series when they're inside the LEDs and the LEDs are in parallel?

They're not inside the LEDs.

I re-drew the schematic with the resistors inside, in series, and it would only use one LED and 1 resistor at a time. It seems to me that would also be true if the resistors were in parallel with the LED. It would seem to me that if you are going to put the resistor inside the LED, you would put it in series to limit current, but it would be fixed to a specific voltage. I dont understand why you would put it in parallel though.

Hippynerd:
I re-drew the schematic with the resistors inside, in series, and it would only use one LED and 1 resistor at a time.

Right. Now go back and read your posts.

Hippynerd:
It seems to me that would also be true if the resistors were in parallel with the LED.

Why on earth would anybody do that?

Yes, i re-read my posts, I dont know why, but I re-read it for you.

I was wondering why anyone would put the resistor in parallel, because you said:

"Not if the resistors are in parallel - which they will be if they're "built in". "

That leads me to believe that you know that the LEDs are in parallel (like thats how they always do it), I've never used those kinds of LEDs, but I would imagine the resistor would be series.