Created
October 31, 2022 10:37
-
-
Save ff6347/1d77c4ce343a0342d62da2a4b6267d57 to your computer and use it in GitHub Desktop.
Revisions
-
ff6347 created this gist
Oct 31, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ 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); }