loading

Back in the 70's I was working for Northern Telecom (Nortel Networks). I attended a digital electronics course and part of the course dealt with LED's and flip flops.

One of the tasks we had to perform was called Running a one through a field of zeros. In this example we have six LEDs that are turned off and each LED had to be turned on then off through the entire sequence of LEDs.

It was a lot of wiring and I probably could not do it today and why would I? Using the Arduino board is so much easier!

This example is for beginners or the curious.

If you want to try this example you will need the following parts:

6 LEDs.

6 330 ohm resistors.

1 Arduino Clone.

7 jumper cables.

1 Breadboard.

You can power this example through the USB port.

======================================================================

Here is the code: You can copy and paste into your IDE.

/* Running a one through a field of zeros This example code is in the public domain. */

// give the LEDs a name and assign them a number:

int led1 = 2;

int led2 = 3;

int led3 = 4;

int led4 = 5;

int led5 = 6;

int led6 = 7;

// the setup routine runs once when you press reset:

void setup() {

// initialize the digital pins as output.

pinMode(led1, OUTPUT);

pinMode(led2, OUTPUT);

pinMode(led3, OUTPUT);

pinMode(led4, OUTPUT);

pinMode(led5, OUTPUT);

pinMode(led6, OUTPUT);

}

// the loop routine runs over and over again forever:

void loop()

{ digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

digitalWrite(led4, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

digitalWrite(led5, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led5, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)

delay(50); // wait

digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW

delay(50); // wait

}

Making things do stuff by writing code is SO much easier!

If you want another challenge try running a zero through a field of ones by changing the code!

I'm sorry for my double comments. I'm typing in the windows phone app that's not really working as it should. I'll remove the comments when I get to the computer. It would be easier for you to use an array for the led pins. This way you can iterate through them using a for loop. Like that your code wouldn't need repetition, so it would be easier to write and to make changes.
<p>Hey. Post the code for the array....It would give people an option they can try.</p><p>Thanks!</p>
<p>Here's the code for the array. It does compile, but I didn't do any further testing (too lazy to make a project in 123circuits :) ). All should work fine.</p><p>/***** START OF CODE *****/<br>/* Running a one through a field of zeros This example code is in the public domain. */<br>// Make an array holding the pins numbers to which the LEDs are connected<br>char led[6] = { 2, 3, 4, 5, 6, 7 };<br><br>// the setup routine runs once when you press reset:<br>void setup() {<br> // for loop is used to access every LED pin (indexes 0-5)<br> for (char i=0; i&lt;6; i++) {<br> // initialize the digital pin (with index i) as output.<br> pinMode(led[i], OUTPUT);<br> }<br>}<br><br>// the loop routine runs over and over again forever:<br>void loop() { <br> // turn LED on, wait a bit then turn it OFF<br> // the for loop takes care of running all the LEDs in sequence<br> for (char i=0; i&lt;6; i++) {<br> // turn the LED (with index i) on (HIGH is the voltage level)<br> digitalWrite(led[i], HIGH); <br> // wait 50 milliseconds<br> delay(50); <br> // turn the LED (with index i) off by making the voltage LOW<br> digitalWrite(led[i], LOW); <br> }<br>}<br>/***** END OF CODE *****/</p>
<p>Yes, thank you!</p><p>This looks great!</p><p>So if anyone wants to try using an array just put rutcorn's code in place of mine and you can see how arrays work...</p><p>Great work Rutcorn!!</p>
<p>You're welcome! I'm happy to be of help.</p>
<p>Thanks for the reply. Yes it would make things easier, however I made this as an example for beginners and wanted to keep it straight forward as possible.</p>

About This Instructable

407views

11favorites

License:

More by AndrewW180:Wiring the PIR  Running a One Through a Field of Zeros Easily Double the Power Output of a  L293D Motor Driver Board 
Add instructable to: