Go Down

Topic: Newbie Multiplexing (I think) Help! (Read 901 times) previous topic - next topic

Nekomancer

Hello,

(Is this the right place to ask this?)

I am familiar with programming, however I am new to electronics.  I have a project where I need to light 17 separate LEDs and be able to control each one individually. However there are only 13 digital pins.
What is the best way to deal with this?

Thanks in Advance,
Zach

CrossRoads

Simplest is to use the analog pins as digital pins.
A0-A5= D14-D19.
Don't forget current limiting resistors on all pins to avoid damaging the arduino pins.

Or get some shift registers, such as 74AC299PC from Newark.com, 56 cents.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nekomancer

Thanks! never knew the analog pins could be used as digital pins! 


GaryP


Thanks! never knew the analog pins could be used as digital pins! 




The idea is simple. Analog out is PWM, about 500Hz.
If you are writing 0, it will be zero out.
If you are writing anything from 1 to 254, the output is anything else than 0 or clear 1.
Just write 255 and it is 1.
Easy

Do you know how PWM works? If yes, then it is easy. If not, ready this and it will be easy. http://en.wikipedia.org/wiki/Pulse-width_modulation
Well, it looks hebrew for me, but just use 1 and 255, and are your 17 outputs at least

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

tomm

You can also just use digitalWrite(A1, HIGH) rather than messing round with 255 each time.

GaryP


You can also just use digitalWrite(A1, HIGH) rather than messing round with 255 each time.


And that was an information I needed, thanks!

Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Nekomancer

Thats neat! I never thought about it in that way.


CrossRoads

You don't need the analog reference at all if using as a digital pin.

signal_out = 14;

pinMode (signal_out, OUTPUT);

digitalWrite (signal_out, HIGH);
or
digitalWrite (signal_out, true);
or
digitalWrite (signal_out, 1);

will put out at a +Vcc signal (5V with a 5V supply) given that you have a proper current limit resistor

while
digitalWrite (signal_out, HIGH);
digitalWrite (signal_out, false);
digitalWrite (signal_out, 0);

will all bring it low, given that you have a proper current limit resistor

LEDs can be driven as shown here

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up