Created
April 20, 2021 17:37
-
-
Save dpnebert/68309dc35ff103f623ac20d0e7e5b3c4 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
#define LED 5 | |
#define POT A7 | |
int in_brightness; | |
int out_brightness; | |
void setup() { | |
in_brightness = analogRead(POT); | |
out_brightness = 0; | |
pinMode(LED, OUTPUT); | |
} | |
void loop() { | |
in_brightness = analogRead(POT); | |
out_brightness = map(in_brightness, 0, 1023, 0, 260); | |
if(out_brightness > 255) { | |
out_brightness = 255; | |
} | |
analogWrite(LED, out_brightness); | |
delay(25); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment