CTRL library / Potentiometers
Basic potentiometer
This sketch demonstrates the basic implementation of a potentiometer.
The code
#include <CtrlPot.h> // Define an onValueChange handlervoid onValueChange(int value) { Serial.print("Basic pot value: "); Serial.println(value);} // Create a potentiometer with the pin number, max. output value, sensitivity margin (can be 0.01 to 100) & onValueChange handler (optional).CtrlPot potentiometer(A0, 100, 0.05, onValueChange); void setup() { Serial.begin(9600);} void loop() { // The process method will keep polling our potentiometer object and handle all it's functionality. potentiometer.process();}