const int StartButton = 2;
#define FV(s) ((__FlashStringHelper*)(s))
const char PROGMEM ff1[] = "ArrowRight";
const char PROGMEM ff2[] = "ArrowUp";
const char PROGMEM ff3[] = "ArrowLeft";
const char PROGMEM ff4[] = "ArrowDown";
const char PROGMEM ff5[] = "Shift";
const char PROGMEM ff6[] = "Alt";
const char PROGMEM ff7[] = "Control";
const char PROGMEM ff8[] = "Enter";
const char PROGMEM ff9[] = "Space";
const char PROGMEM ff10[] = "Backspace";
const char *strings[] =
{ ff1,
ff2,
ff3,
ff4,
ff5,
ff6,
ff7,
ff8,
ff9,
ff10,
};
const int NumButtons = sizeof(strings) / sizeof(char*);
void setup() {
Serial.begin(115200);
Serial.println("This has button-shortcuts on keys per https://github.com/wokwi/wokwi-features/issues/904");
Serial.print(NumButtons);
Serial.println(" pins configured:");
for (int ii = 0 ; ii < NumButtons; ++ii ) {
int pin = StartButton + ii;
pinMode(pin, INPUT_PULLUP);
Serial.print(pin);
Serial.print(": ");
Serial.println(FV(strings[ii]));
}
}
void loop() {
// put your main code here, to run repeatedly:
checkButtons();
delay(300);
}
void checkButtons() {
for (int ii = 0 ; ii < NumButtons; ++ii ) {
int pin = StartButton + ii;
if (digitalRead(pin) == LOW) {
Serial.print(FV(strings[ii]));
Serial.print(" ");
}
}
}