Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Created March 25, 2021 16:22
Show Gist options
  • Save cbscribe/214efffed1773360521ea4820bc65b2e to your computer and use it in GitHub Desktop.
Save cbscribe/214efffed1773360521ea4820bc65b2e to your computer and use it in GitHub Desktop.
Blink a row of 8 leds using a potentiometer
void setup()
{
for (int i=6; i<=13; i++)
{
pinMode(i, OUTPUT);
}
}
int n = 13;
int add = -1;
void loop()
{
digitalWrite(n, HIGH);
int d = map(analogRead(A5), 0, 1023, 100, 500);
delay(d);
digitalWrite(n, LOW);
n += add;
if (n == 5)
{
add = 1;
}
if (n == 14) {
add = -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment