Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code for master final project's board
- #include <TinyWireM.h>
- int LED=0;
- void setup() {
- TinyWireM.begin(); //initialization of communication
- pinMode(LED,OUTPUT);
- delay(200);
- }
- void loop() {
- TinyWireM.requestFrom(8,1); //asks the slave #8 to send a byte
- while(TinyWireM.available()){ //puts what it's got into 'got' variable
- int got=TinyWireM.receive();
- if (got == 1){ //if the slave sent '1', the master turns led on for 3 seconds
- digitalWrite(LED, HIGH);
- delay(700);
- digitalWrite(LED, LOW);
- delay(100);
- }
- if (got == 0){ //if the slave sent '0', the master blinks LED twice
- digitalWrite(LED, HIGH);
- delay(100);
- digitalWrite(LED, LOW);
- delay(100);
- digitalWrite(LED, HIGH);
- delay(100);
- digitalWrite(LED, LOW);
- delay(100);
- }
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment