/* attiny_i2c_slave2.ino by Lucas Lim created on 4/05/2020 Purpose: Receive data from MASTER via the I2C bus Blink the LED The work is provided for academic purpose for Fab Academy 2020. Users accept all as is, no warranty is provided, no call/email from users will get a response. Users accept all liability. */ #include #define i2c_slave2 2 const int ledPin = 4; //PB4 - Arduino Pin No. 4 //int times = 0; //Number of times that LED will blink byte received = 0; //Received data(on number of times that LED will blink) from MASTER void setup() { TinyWireS.begin(i2c_slave2); // join I2C bus as slave } void blink_led(int times) { while(times--) { digitalWrite(ledPin, HIGH); delay(500); digitalWrite(ledPin, LOW); delay(500); } } void loop() { if (TinyWireS.available()) { received = TinyWireS.receive(); blink_led(received); } received = 0; // This needs to be here TinyWireS_stop_check(); }