//Original code made by Pablo Nuñez, available at https://hackmd.io/@ihhYfPp3TlKoBY_QfN2kZQ/S13ZXYK9U //Translated and edited by Jonathan León //This code is for the master board, connect it to a breadboard with wires on TX, 5V and GND //on three different lines. //The slave(s) board(s) uses almost the same connections but using the RX pin instead. //Connect the LED with the positive leg on the 13 pin and the negative leg on the next pin (GND). #define BUTTON_PIN 8 //Button boolean oldState = HIGH; //Initial button state int mode = 0; //Initial mode void setup() { Serial.begin (9600); //Starts serial monitor pinMode(BUTTON_PIN, INPUT_PULLUP); //Sets the button as an input } void loop() { boolean newState = digitalRead(BUTTON_PIN); if((newState == LOW) && (oldState == HIGH)) { delay(20); // Short delay to debounce button. newState = digitalRead(BUTTON_PIN); // Check if button is still low after debounce. if(newState == LOW) { // Yes, still low if(++mode > 1) mode = 0; // Advance to next mode, wrap around after #2 switch(mode) { // Start the new animation... case 0: Serial.write('a'); //Calls the slave board ("a") delay(1000); break; case 1: Serial.write('b'); //Calls the slave board ("b") delay(1000); break; //When using more than two slave boards add more Cases and update ++mode > 1 on line 20 } } } oldState = newState; //Update the button state }