-
-
Save JeffersGlass/27cbbfae209b5249c651fdc724834ea5 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
const int buttonPin = 2; | |
const int ledPin = 9; | |
volatile int countdown = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(buttonPin, INPUT_PULLUP); | |
pinMode(ledPin, OUTPUT); | |
attachInterrupt(digitalPinToInterrupt(2), setState, FALLING); | |
} | |
void loop() { | |
analogWrite(ledPin, countdown); | |
countdown = max(countdown-10, 0); | |
delay(100); | |
} | |
void setState(){ | |
countdown = 255; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment