Last active
April 23, 2016 11:11
-
-
Save abcdmitry/247ec4809f4865621266a2999ae79519 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 led = 7 | |
byte brightness = 20 | |
int detect = 9 | |
int bright_max = 255 | |
int bright_min = 20 | |
const CLOSED = LOW; | |
const OPEN = HIGH; | |
pinMode(led, OUTPUT); | |
pinMode(detect, INPUT); | |
void setup(){ | |
} | |
void loop() { | |
if (digitalRead(detect) == LOW && brightness > bright_min) { | |
brightness--; | |
analogWrite(led, brightness); | |
delay(10); | |
} else if (digitalRead(detect) == HIGH && brightness < bright_max) { | |
brightness++; | |
analogWrite(led, brightness); | |
delay(10); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment