Pages: [1] 2   Go Down
Author Topic: Help with programming an LED knight-rider scanner!  (Read 1909 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :/ 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
Code:
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
« Last Edit: February 20, 2013, 03:19:05 pm by Zakc » Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.





Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".

« Last Edit: February 20, 2013, 02:50:19 pm by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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 <i>will</i> be if they're "built in".


Do you suggest i try something else then?
Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 <i>will</i> 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.
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.lmgtfy.com/?q=led+with+built+in+resistor


Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://www.lmgtfy.com/?q=led+with+built+in+resistor




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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26621
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
« Last Edit: February 20, 2013, 03:06:18 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@fungus, why in parallel?

I never said 'parallel', that was Hippynerd.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!
Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@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?
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5742
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1] 2   Go Up
Jump to: