Created
January 21, 2018 22:39
-
-
Save Youz13/3f3a10ba20cdeb7fb0054ce0dce8db24 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
cyclecompt = 0; | |
while (cyclecompt < 220) { | |
analogWrite(led, brightness); | |
brightness = brightness + fadeAmount; | |
if ( brightness <= 10 ) { // On ending invert fadeAmount for next fade in | |
fadeAmount = -fadeAmount; | |
delay(1000); | |
} | |
if ( brightness >= 115 ) { // If led is full bright, invert fadeAmount to fade out | |
fadeAmount = -fadeAmount; | |
} | |
delay(delayM); | |
cyclecompt++; | |
if (digitalRead(mode) == HIGH) { | |
button_delay = 0; | |
while (digitalRead(mode) == HIGH) { | |
button_delay++; | |
delay(100); | |
if (button_delay > 10) { //no need to wait for user to release | |
digitalWrite(9, LOW); | |
digitalWrite(10, LOW); | |
EnD(); | |
break; | |
} | |
} | |
if (button_delay < 10) { //short press | |
if (led == 9) { | |
for (int fadeValue = brightness ; fadeValue >= 0; fadeValue -= 5) { | |
analogWrite(9, fadeValue); | |
delay(30); | |
} | |
digitalWrite(9, LOW); | |
led = 10; button_delay = 0; | |
} | |
else { | |
for (int fadeValue = brightness ; fadeValue >= 0; fadeValue -= 5) { | |
analogWrite(10, fadeValue); | |
delay(30); | |
} | |
digitalWrite(10, LOW); | |
led = 9; button_delay = 0; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment