Pages: [1]   Go Down
Author Topic: Newbie Multiplexing (I think) Help!  (Read 692 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 444
Posts: 23859
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

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

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

Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


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

Derby
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


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

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

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

Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 444
Posts: 23859
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: