#define DEBUG
#include "INHK_Pot2.h"
#define POT_NUM 6 // number of potentiometers
#define POT_THRESHOLD 5 // sets the sensibility of the potentiometers, increase value if potentiometer is jittering
#define ALPHA 0.75 // set the Alpha veriable for the for leaky integrator to smooth output, between 0.01 and 1.00
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
//**********************************************************************************************************************************************
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); // sets threshold
Pot[i].setAlphaValue(ALPHA); // sets alpha value
#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.print("\t");
Serial.print(" Alpha Value: ");
Serial.print(Pot[i].alpha);
Serial.println("\t");
#endif
}
}
//**********************************************************************************************************************************************
void loop() {
for(int i = 0 ; i < POT_NUM; i ++){ // read the pot values
potReading [i] = Pot[i].readValue();
}
#ifdef DEBUG
Serial.print("Pot n1: "); // prints current potentiometers reading
Serial.println(potReading [0]);
#endif
}