#define DEBUG
#include "INHK_Pot4.h"
#define POT_NUM 6 // number of potentiometers
// creates a number (POT_NUM) of objects of Potentiometer class and passes the pin number as argument, and second parameter for range ie. see below:
Potentiometer Pot[POT_NUM] = {{(A0), 2}, (A1), (A2), (A3), (A4), (A5)}; // (0 - 3) range of pot output ie: 0 = 0-1022; 1 = 0-511; 2 = 0-255; 3 = 0-12
int potReading [POT_NUM]; // variableto store the returned potentiometers reading values
//**********************************************************************************************************************************************
void setup() {
#ifdef DEBUG
Serial.begin(9600);
Serial.print("Number of pots: ");
Serial.println(Potentiometer::getCounter()); // returns the number of objects (pots) created
#endif
}
//**********************************************************************************************************************************************
void loop() {
updateAllPots();
}
void updateAllPots() {
for (int i = 0; i < POT_NUM; i++) {
// Read both raw and smoothed values
int rawValue = Pot[i].readValue();
int smoothValue = Pot[i].readSmoothValue(0.75); // return smoot value change range for smoothing from 0.01 (nearly raw - fast) to 0.99 (very gradual - slow)
#ifdef DEBUG
Serial.print(F("Pot #"));
Serial.print(i + 1);
Serial.write('\t');
// Print raw value
Serial.print(F("Raw: "));
Serial.print(rawValue);
Serial.write('\t');
// Print smoothed value
Serial.print(F("Smooth: "));
Serial.print(smoothValue);
Serial.write((i == POT_NUM - 1) ? '\n' : '\t');
#endif
}
}