Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Created October 24, 2018 10:45
Show Gist options
  • Save pinglunliao/5c33d827df257ff094e86eceeff9cf1a to your computer and use it in GitHub Desktop.
Save pinglunliao/5c33d827df257ff094e86eceeff9cf1a to your computer and use it in GitHub Desktop.
int sPin = 2; // The base pin ID
int nLEDs = 10; // The number of LEDs
int delayMS = 100;
void setup()
{
for (int i = sPin; i < sPin + nLEDs; i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
for(int i = sPin; i < sPin + nLEDs; i++)
{
digitalWrite(i, LOW);
delay(delayMS);
}
for(int i = sPin; i < sPin + nLEDs; i++)
{
digitalWrite(i, HIGH);
delay(delayMS);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment