Created
October 1, 2017 02:31
-
-
Save ulrichzwingli/27a4b1290a8f2c235e8dfa794a36f35e to your computer and use it in GitHub Desktop.
Potentiometer dimming LED
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 analog_range; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
pinMode(8, OUTPUT); | |
pinMode(13, OUTPUT); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
analog_range = analogRead(A0); | |
if (analog_range<=512) { | |
digitalWrite(8, HIGH); | |
digitalWrite(13, LOW); | |
} | |
else | |
{ | |
brightness = brightness + fade; | |
if (brightness == 0 || brightness ==255) | |
{ | |
fade = -fade; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment