Created
March 25, 2021 16:22
-
-
Save cbscribe/214efffed1773360521ea4820bc65b2e to your computer and use it in GitHub Desktop.
Blink a row of 8 leds using a potentiometer
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
| 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