docs about normalising potpin

This commit is contained in:
2025-02-17 17:03:24 +01:00
parent 72bf01a813
commit af6a2916ab
2 changed files with 91 additions and 5 deletions

View File

@@ -1,13 +1,32 @@
#include <Arduino.h>
// declarations
int normalizePot(int pin, int minValue);
// constants
const int potPin1 = 0;
void setup(){
void setup()
{
Serial.begin(9600);
pinMode(0, INPUT);
pinMode(potPin1, INPUT);
}
void loop(){
Serial.println(analogRead(0));
void loop()
{
Serial.println(normalizePot(potPin1, 80));
}
int normalizePot(int pin, int minValue)
{
int pot = analogRead(pin);
if (pot <= minValue)
{
return 80;
}
else
{
return pot;
}
}