Go Down

### Topic: Help with programming an LED knight-rider scanner! (Read 3225 times)previous topic - next topic

#### Zakc

##### Feb 20, 2013, 07:50 pmLast Edit: Feb 20, 2013, 09:19 pm by Zakc Reason: 1
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: [Select]
`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

#### Hippynerd

#1
##### Feb 20, 2013, 08:04 pm
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.

#### Zakc

#2
##### Feb 20, 2013, 08:07 pm
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!

#### fungus

#3
##### Feb 20, 2013, 08:23 pm
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.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### fungus

#4
##### Feb 20, 2013, 08:24 pmLast Edit: Feb 20, 2013, 08:50 pm by fungus Reason: 1

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

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

#### Zakc

#5
##### Feb 20, 2013, 08:35 pm

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?

#### Hippynerd

#6
##### Feb 20, 2013, 08:45 pm

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.

#### fungus

#7
##### Feb 20, 2013, 08:49 pm

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.

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

#### fungus

#8
##### Feb 20, 2013, 08:53 pm

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

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

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

#### Zakc

#9
##### Feb 20, 2013, 09:00 pm

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!

#### AWOL

#10
##### Feb 20, 2013, 09:04 pmLast Edit: Feb 20, 2013, 09:06 pm by AWOL Reason: 1
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?
"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.

#### fungus

#11
##### Feb 20, 2013, 09:12 pm

@fungus, why in parallel?

I never said 'parallel', that was Hippynerd.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### Zakc

#12
##### Feb 20, 2013, 09:18 pm

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!

#### Hippynerd

#13
##### Feb 20, 2013, 09:29 pm

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

#### fungus

#14
##### Feb 20, 2013, 09:45 pm

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?

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

Go Up

Please enter a valid email to subscribe