Created
February 10, 2014 21:42
-
-
Save arielchuri/8924808 to your computer and use it in GitHub Desktop.
Code for testing your 6 LEDs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int timer = 60; // The higher the number, the slower the timing. | |
| int ledPins[] = { | |
| 11, 10, 9, 6, 5, 3 }; // an array of pin numbers to which LEDs are attached | |
| int pinCount = 6; // the number of pins (i.e. the length of the array) | |
| void setup() { | |
| // the array elements are numbered from 0 to (pinCount - 1). | |
| // use a for loop to initialize each pin as an output: | |
| for (int thisPin = 0; thisPin < pinCount; thisPin++) { | |
| pinMode(ledPins[thisPin], OUTPUT); | |
| } | |
| } | |
| void loop() { | |
| // loop from the lowest pin to the highest: | |
| for (int thisPin = 0; thisPin < pinCount; thisPin++) { | |
| // turn the pin on: | |
| digitalWrite(ledPins[thisPin], HIGH); | |
| delay(timer); | |
| // turn the pin off: | |
| digitalWrite(ledPins[thisPin], LOW); | |
| } | |
| // loop from the highest pin to the lowest: | |
| for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { | |
| // turn the pin on: | |
| digitalWrite(ledPins[thisPin], HIGH); | |
| delay(timer); | |
| // turn the pin off: | |
| digitalWrite(ledPins[thisPin], LOW); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment