Created
March 27, 2017 05:49
-
-
Save stuntguy3000/60f7c5f426f839a8d823f8c81f57cdb7 to your computer and use it in GitHub Desktop.
This file contains 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 led1 = 2; | |
int led2 = 3; | |
int led3 = 4; | |
int button = 7; | |
boolean enabled = true; | |
void setup() | |
{ | |
pinMode(led1, OUTPUT); | |
pinMode(led2, OUTPUT); | |
pinMode(led3, OUTPUT); | |
pinMode(button, INPUT_PULLUP); | |
} | |
void loop() | |
{ | |
enableLED(led1); | |
delay(analogRead(A0)); | |
enableLED(led2); | |
delay(analogRead(A0)); | |
enableLED(led3); | |
delay(analogRead(A0)); | |
} | |
void enableLED(int value) { | |
int buttonState = digitalRead(button); | |
if (buttonState == HIGH) { | |
enabled = !enabled; | |
} | |
analogWrite(led1, 0); | |
analogWrite(led2, 0); | |
analogWrite(led3, 0); | |
if (enabled) { | |
analogWrite(value, 255); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment