#define analogPin A2
const int cutoffsLow[] = {200, 600, 1200, 1800, 2400}; // low thresholds
const int cutoffsHigh[] = {600, 1200, 1800, 2400, 3500}; // high thresholds
void setup() {
Serial.begin(9600);
}
void loop() {
// button colors are from left to right in schematic
// green, white, yellow, blue and red
int val = analogRead(analogPin);
if (val > 0) {
Serial.print("Raw reading=" + String(val));
if ((val > cutoffsLow[4]) && (val < cutoffsHigh[4])) {
Serial.println(" Red button pushed.");
}
if ((val > cutoffsLow[3]) && (val < cutoffsHigh[3])) {
Serial.println(" Blue button pushed.");
}
if ((val > cutoffsLow[2]) && (val < cutoffsHigh[2])) {
Serial.println(" Yellow button pushed.");
}
if ((val > cutoffsLow[1]) && (val < cutoffsHigh[1])) {
Serial.println(" White button pushed.");
}
if ((val > cutoffsLow[0]) && (val < cutoffsHigh[0])) {
Serial.println(" Green button pushed.");
}
delay(500);
}
}