#include <Toggle.h>
class augmentedButton : public Toggle {
public:
byte bPin;
const char* label1;
const char* label2;
augmentedButton(const byte p, const char* l1, const char* l2) :
Toggle(p), bPin(p), label1(l1), label2(l2) {}
void begin() {
Toggle::begin(bPin);
}
};
const byte potPin = A0;
augmentedButton buttons[] = {
{3, "yellow", "YELLOW"},
{4, "blue", "BLUE"},
{5, "red", "RED"},
{6, "green", "GREEN"},
};
void setup() {
for (auto& b : buttons) b.begin();
Serial.begin(115200);
}
void loop() {
bool shifted = analogRead(potPin ) >= 512;
for (auto& b : buttons) {
b.poll();
if (b.onPress()) {
Serial.println(shifted ? b.label1 : b.label2);
}
}
}