mirror of
https://gitlab.waag.org/make/fablab/interns/2025/sam.git
synced 2025-08-04 04:14:56 +00:00
docs about normalising potpin
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user