/////////////////////////////ATyiny1614 //define pins ////// I2C #define SCL_pin B0 #define SDA_pin B1 ////// SERIAL // #define Tx_pin B2 // #define Rx_pin B3 ////// UPDI // #define UPDI_pin A0 ////// SPI #define MOSI_pin A1 #define MISO_pin A2 #define SCK_pin A3 #define CS_pin A4 ////// OUTPUTS #define LED1_pin A5 #define LED2_pin A6 /////// INPUT #define BTN_pin A7 ////////////////////////////// ///////// INCLUDES /////////// #include ///////////// VARIABLES ////// int baudRate = 9600; int broadcastDelay = 500; byte Modus = 1; int totalModes = 2; ////////////////////////////// void setup() { // put your setup code here, to run once: // INPUT pinMode(BTN_pin, INPUT_PULLUP); // OUPUTS pinMode(LED1_pin, OUTPUT); pinMode(LED2_pin, OUTPUT); // Serial - FTDI Serial.begin(baudRate); while (!Serial); //// I2C COMMS Wire.begin(); // join i2c bus (address optional for master) } void loop() { // put your main code here, to run repeatedly: if (digitalRead(BTN_pin) == LOW) { Broadcast(1, Modus); // send Node 1 a number Broadcast(2, Modus); // send Node 2 a number if(Modus>=totalModes){ Modus= 0; //reset; }else{ Modus++; } delay(broadcastDelay); } } /////////////// Broadcast ///////// void Broadcast(int whichAddress, byte myMessage) { Serial.println("------------------BROADCAST START"); Serial.print(whichAddress); Serial.print(","); Serial.println(myMessage); //// Wire.beginTransmission(whichAddress); // transmit to device #4 Blink(LED1_pin); // controller feedback Wire.write(myMessage); // sends bytes Wire.endTransmission(); // stop transmitting Blink(LED2_pin); // controller feedback Serial.println("------------------BROADCAST END"); }