// video switch control panel
// https://wokwi.com/projects/348441099924144723
const byte MAXBUTTONS = 18; // room for 18
const byte REALBUTTONS = 4; // only four actually in the tables and wired
const byte buttonPin[MAXBUTTONS] =
{
25, 27, 29, 31, // and so forth, the pins where the buttons are
};
const char letterToSend[MAXBUTTONS] =
{
's', 'd', 'v', 'k', // the character to send
};
const byte ledPin[MAXBUTTONS] =
{
2, 3, 4, 5, // the pins where the LEDs are
};
const unsigned long videoDuration[MAXBUTTONS] = {
4000, 5000, 6000, 77000UL, // the duration in ms of the videos
};
const int stupidTurnOnDelayFactor = 2000; // waaaaay too long!
void doCheckButtons()
{
for (unsigned char buttonN = 0; buttonN < REALBUTTONS; buttonN++) {
if (digitalRead(buttonPin[buttonN]) == 0) // if button is pressed
{
// I don't have a Leonardo or Due, so no
// Keyboard.write(letterToSend[buttonN]); // send a single letter
Serial.print("launching '");
Serial.print(letterToSend[buttonN]);
Serial.println("'...");
delay(stupidTurnOnDelayFactor);
digitalWrite(ledPin[buttonN], HIGH); //turn on the led
delay(videoDuration[buttonN]);
digitalWrite(ledPin[buttonN], LOW); //turn off the led after duration + stupidFactor
Serial.println(" and back waiting...");
}
}
}
void setup() {
Serial.begin(115200);
Serial.println("hello world!\n");
for (unsigned char buttonN = 0; buttonN < REALBUTTONS; buttonN++) {
pinMode(buttonPin[buttonN], INPUT_PULLUP);
pinMode(ledPin[buttonN], OUTPUT);
digitalWrite(ledPin[buttonN], LOW);
}
}
void loop() {
doCheckButtons();
}