Introduction: How to Control 12 Led With Uno

This is my first instructable and I want to thank Oadil for his instructable Trafik light, 9 led using Arduino UNO I bought a simple UNO micro controller and I was looking for an easy project to be able to understand the inputs and the outputs. Check out his instruct able to see the first steps and how to connect the led with the different outputs. I could just copy his text but I really wanna give him some credit. I spent several days before I found help.

Step 1: Trafik Lights

int led2 = 2;

int led3 = 3; int del=1000; int led4 = 4; int led5 = 5; int led6 = 6; int led7 = 7; int led8 = 8; int led9 = 9; int led10 = 10;

// the set up routine runns once when you press reset:

void setup () { // initialize the digital pin as oupput.

pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); pinMode(led7, OUTPUT); pinMode(led8, OUTPUT); pinMode(led9, OUTPUT); pinMode(led10, OUTPUT); } //the loop routine runs over and over again forever:

void loop(){

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

//All red

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

delay(del*2);

// GREEN1

digitalWrite(led2, LOW); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

delay(del);

//YELLOW1

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

delay(del/2);

//ALL RED

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

delay(del*2);

//GREEN 2

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, HIGH); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW); delay(del);

//YELLOW2

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, LOW); digitalWrite(led10, LOW);

delay(del/2);

//ALL RED

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, HIGH);

delay(2*del);

//GREEEN2

digitalWrite(led2, HIGH); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, HIGH); digitalWrite(led10, LOW);

delay(del);

//YELLOW3

}

Step 2: Christmas Lights

Now that I understood a lille bit more I wanted to play and explore some possibilities.

Observe that the fist two columns are just the same. but I added three more outputs and tried to make it work like the christmas lights.

Copy and paste the code below.

int led2 = 2;
int led3 = 3; int del=1000; int led4 = 4; int led5 = 5; int led6 = 6; int led7 = 7; int led8 = 8; int led9 = 9; int led10 = 10; int led11= 11; int led12= 12; int led13= 13;

// the set up routine runns once when you press reset:

void setup () { // initialize the digital pin as oupput.

pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); pinMode(led7, OUTPUT); pinMode(led8, OUTPUT); pinMode(led9, OUTPUT); pinMode(led10, OUTPUT); pinMode(led11, OUTPUT); pinMode(led12, OUTPUT); pinMode(led13, OUTPUT); }

// ALL ON

void loop(){ digitalWrite(led2, HIGH); delay(del); digitalWrite(led3, HIGH); delay(del/2); digitalWrite(led4, HIGH); delay(del/3); digitalWrite(led5, HIGH); delay(del/4); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/6); digitalWrite(led8, HIGH); delay(del/7); digitalWrite(led9, HIGH); delay(del/8); digitalWrite(led10, HIGH); delay(del/9); digitalWrite(led11, HIGH); delay(del/10); digitalWrite(led12, HIGH); delay(del/11); digitalWrite(led13, HIGH); delay(del);

// ALL OFF

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); delay(del/3); digitalWrite(led3, HIGH); delay(del/3); digitalWrite(led4, HIGH); delay(del/3); digitalWrite(led5, HIGH); delay(del/3); digitalWrite(led6, HIGH); delay(del/3); digitalWrite(led7, HIGH); delay(del/3); digitalWrite(led8, HIGH); delay(del/3); digitalWrite(led9, HIGH); delay(del/3); digitalWrite(led10, HIGH); delay(del/3); digitalWrite(led11, HIGH); delay(del/3); digitalWrite(led12, HIGH); delay(del/3); digitalWrite(led13, HIGH); delay(del);

// ALL OFF

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led13, HIGH); delay(del);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led13, HIGH); delay(del);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led13, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4); digitalWrite(led13, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led2, HIGH); delay(del);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH);

delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, HIGH);

delay(del/4);

digitalWrite(led3, LOW); digitalWrite(led4, HIGH);

delay(del/4);

digitalWrite(led4, LOW); digitalWrite(led5, HIGH);

delay(del/4);

digitalWrite(led5, LOW); digitalWrite(led6, HIGH);

delay(del/4);

digitalWrite(led6, LOW); digitalWrite(led7, HIGH);

delay(del/4);

digitalWrite(led7, LOW); digitalWrite(led8, HIGH);

delay(del/4);

digitalWrite(led8, LOW); digitalWrite(led9, HIGH);

delay(del/4);

digitalWrite(led9, LOW); digitalWrite(led10, HIGH);

delay(del/4);

digitalWrite(led10, LOW); digitalWrite(led11, HIGH);

delay(del/4);

digitalWrite(led11, LOW); digitalWrite(led12, HIGH);

delay(del/4);

digitalWrite(led12, LOW); digitalWrite(led13, HIGH); delay(del/4);

digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led13, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led13, HIGH); delay(del/5); digitalWrite(led12, HIGH); delay(del/5); digitalWrite(led11, HIGH); delay(del/5); digitalWrite(led10, HIGH); delay(del/5); digitalWrite(led9, HIGH); delay(del/5); digitalWrite(led8, HIGH); delay(del/5); digitalWrite(led7, HIGH); delay(del/5); digitalWrite(led6, HIGH); delay(del/5); digitalWrite(led5, HIGH); delay(del/5); digitalWrite(led4, HIGH); delay(del/5); digitalWrite(led3, HIGH); delay(del/5); digitalWrite(led2, HIGH); delay(del);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH);

delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH);

delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, HIGH);

delay(del/4);

digitalWrite(led3, LOW); digitalWrite(led4, HIGH);

delay(del/4);

digitalWrite(led4, LOW); digitalWrite(led5, HIGH);

delay(del/4);

digitalWrite(led5, LOW); digitalWrite(led6, HIGH);

delay(del/4);

digitalWrite(led6, LOW); digitalWrite(led7, HIGH);

delay(del/4);

digitalWrite(led7, LOW); digitalWrite(led8, HIGH);

delay(del/4);

digitalWrite(led8, LOW); digitalWrite(led9, HIGH);

delay(del/4);

digitalWrite(led9, LOW); digitalWrite(led10, HIGH);

delay(del/4);

digitalWrite(led10, LOW); digitalWrite(led11, HIGH);

delay(del/4);

digitalWrite(led11, LOW); digitalWrite(led12, HIGH);

delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); delay(del/4); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW); delay(del/4); }

Step 3: Forward Movement

I was thinking in a worm when I wrote this.

int led2 = 2;

int led3 = 3; int del=1000; int led4 = 4; int led5 = 5; int led6 = 6; int led7 = 7; int led8 = 8; int led9 = 9; int led10 = 10; int led11= 11; int led12= 12; int led13= 13;

// the set up routine runns once when you press reset:

void setup () { // initialize the digital pin as oupput.

pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); pinMode(led7, OUTPUT); pinMode(led8, OUTPUT); pinMode(led9, OUTPUT); pinMode(led10, OUTPUT); pinMode(led11, OUTPUT); pinMode(led12, OUTPUT); pinMode(led13, OUTPUT); }

void loop(){ digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); delay(del/4); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); delay(del/4);

digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, HIGH); digitalWrite(led11, HIGH); delay(del/4);

digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, HIGH); digitalWrite(led9, HIGH); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, HIGH); digitalWrite(led13, HIGH); delay(del/4); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); digitalWrite(led7, LOW); digitalWrite(led8, LOW); digitalWrite(led9, LOW); digitalWrite(led10, LOW); digitalWrite(led11, LOW); digitalWrite(led12, LOW); digitalWrite(led13, LOW);

}

Comments

author
ofir60 made it!(author)2015-01-01

Awesome ideas!

For the next times, I'd recommend you learning about:

Charlieplexing,Shift-Register, and for loops to make less code writing/less pins.

Send me a PM if you want further explaining :)

author
Otech2012 made it!(author)2015-12-06

Hi can you please help me to learn about shift ref and chsrliplexing ? Whatever info you can send me I appricated I am new to Arduino where I can Lear to program? Thanks

author
luzm made it!(author)2015-01-04

Thanks! maybe it looks like a lot of coding, but I just created two rows of code and changed a single thing avery time, then I copied and pasted a lot of times. I'll try to use less pins in the future, but how can I have control over every single one? I have some sequences that may require it.

author
ofir60 made it!(author)2015-01-04

About the code- I got it, but you can use loops to make it shorter and easier to make.
for and while.
As for using less pins, you can do that using shift-register, he uses 3 pins and gets 8 outputs.
Here's an example for one.
https://www.sparkfun.com/products/733
To learn more, read these articles:
http://www.idogendel.com/en/archives/211
It has 3 parts, look at the update part below.
Have fun!

author
luzm made it!(author)2015-01-07

Oh, I understand what you mean now. I don't have shift-register yet, but I'm expecting a couple.

author
violinsinalma made it!(author)2014-12-19

Nice!

author
seamster made it!(author)2014-12-19

Coo, thanks for sharing this!

author
luzm made it!(author)2014-12-19

Thanks! I really appreciate . :-)

About This Instructable

4,106views

13favorites

License:

Bio: I like to learn new things. I really enjoy it. Learning makes me feel alive.
More by luzm:Recycled turning table with 3D-printed partsArduinoCnc
Add instructable to: