//https://forum.arduino.cc/t/midi-controller-4-pots-on-one-lcd/1190027
#include <LiquidCrystal_I2C.h> // if you don´t have I2C version of the display, use LiquidCrystal.h library instead
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
// define your input data
struct Input {
const uint8_t pin; // the ADC pin you want to measure
uint16_t previousValue; // store the old value
};
// define your inputs
Input input[] {
{A0, 0},
{A1, 0},
{A2, 0},
{A3, 0},
};
constexpr uint8_t threashold = 1;
void setup() {
lcd.init(); // initialize the 16x2 lcd module
lcd.backlight(); // enable backlight for the LCD module
lcd.println(F("Measure ADC"));
delay(500); // show startup message
}
void loop() {
for (auto &i : input) {
// Input
int currentValue = analogRead(i.pin); // int is acceptable as we await 0..1023 only
// Process
int difference = currentValue - i.previousValue;
difference = abs(difference);
// Output
if (difference >= threashold) { // only print when new value has changed enough
lcd.setCursor(0, 0);
lcd.print(F("ADC pin"));
lcd.print(i.pin);
lcd.print('=');
lcd.print(currentValue);
lcd.print(F(" ")); // delete "old" remaining characters
i.previousValue = currentValue;
}
}
}