Skip to content

Instantly share code, notes, and snippets.

@zetlan
Last active December 16, 2016 14:51
Show Gist options
  • Save zetlan/4d04fb646b8dab57b0ca032fd167b57c to your computer and use it in GitHub Desktop.
Save zetlan/4d04fb646b8dab57b0ca032fd167b57c to your computer and use it in GitHub Desktop.
Davis's LED ring code
/*
Simple Arduino program to turn a series of pins controlling LEDs on and off
in sequence. Each pin/LED remains on for the same period of time.
*/
/*
Set the first and last pins, and the time for which pins will be on. These
numbers are "inclusive" – pins X through Y, including both X and Y.
Delay is in milliseconds.
*/
int pinStart = 2;
int pinStop = 9;
int pinDelay = 1000; // 1000 milliseconds; i.e., 1 second
/*
Initial setup for all the pins: set for output, and turned off.
*/
void setup() {
for (int current_pin = pinStart; current_pin <= pinStop; current_pin++) {
pinMode(current_pin, OUTPUT);
digitalWrite(current_pin, LOW);
}
}
/*
For each pin, do the following:
1. Turn it on
2. Wait for the appropriate amount of time
3. Turn it off.
*/
void loop() {
for (int current_pin = pinStart; current_pin <= pinStop; current_pin++) {
digitalWrite(current_pin, HIGH);
delay(pinDelay);
digitalWrite(current_pin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment