Go Down

### Topic: Newbie Multiplexing (I think) Help! (Read 1 time)previous topic - next topic

#### Nekomancer

##### Mar 20, 2011, 05:01 am
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?

Zach

#1
##### Mar 20, 2011, 05:19 am
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

#2
##### Mar 20, 2011, 05:35 am
Thanks! never knew the analog pins could be used as digital pins!

#### GaryP

#3
##### Mar 20, 2011, 09:03 am

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

#4
##### Mar 20, 2011, 11:06 am
You can also just use digitalWrite(A1, HIGH) rather than messing round with 255 each time.

#### GaryP

#5
##### Mar 20, 2011, 11:18 am

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

#6
##### Mar 20, 2011, 03:04 pm
Thats neat! I never thought about it in that way.

#7
##### Mar 20, 2011, 03:10 pm
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

Please enter a valid email to subscribe