Created
October 31, 2022 10:37
-
-
Save ff6347/1d77c4ce343a0342d62da2a4b6267d57 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 poti = A0; | |
int led = 9; | |
int inMax = 0; | |
int inMin = 1023; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(led, OUTPUT); | |
} | |
void loop() { | |
int value = analogRead(poti); | |
if (inMin > value) { | |
inMin = value; | |
} | |
if (inMax < value) { | |
inMax = value; | |
} | |
int mapped_value = map(value, | |
inMin, | |
inMax, | |
0, | |
255); | |
// analogWrite(led, mapped_value); // or devide value by 4 | |
Serial.println(mapped_value); | |
// Serial.println(inMin); | |
// Serial.println(inMax); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment