#define DEBUG
#include "INHK_SimplePot.h"
#define POT_NUM 6 // number of potentiometers
#define POT_THRESHOLD 5 // sets the sensibility of the potentiometers, increase value if potentiometer is jittering
Potentiometer Pot[POT_NUM] = {(A0), (A1), (A2), (A3), (A4), (A5)}; // creates a number (POT_NUM) of objects of Potentiometer class and passes the pin number as argument
int potReading [POT_NUM]; // variable for the potentiometer reading values returned
#ifdef DEBUG
int potPrevReading [POT_NUM] = {0, 0, 0, 0, 0, 0}; // only needed for debugging
#endif
void setup() {
#ifdef DEBUG
Serial.begin(9600);
#endif
for(int i = 0 ; i < POT_NUM; i ++){ // read the pot values
Pot[i].setThreshold(POT_THRESHOLD);
#ifdef DEBUG
Serial.print("Pot n: "); // prints potentiometers threshold (sensibility) at start
Serial.print(i+1);
Serial.print(" threshold: ");
Serial.print(Pot[i].threshold);
Serial.println("\t");
#endif
}
}
void loop() {
for(int i = 0 ; i < POT_NUM; i ++){ // read the pot values
potReading [i] = Pot[i].readValue();
if (potReading[i] != potPrevReading[i]){
#ifdef DEBUG
Serial.print("Pot n: "); // prints current potentiometers reading
Serial.print(i+1);
Serial.print(" >> ");
Serial.print(potReading [i]);
Serial.println("\t");
#endif
potPrevReading [i] = potReading [i];
}
}
}