Advertisement
BnEc

Slave

Feb 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <Wire.h>
  2.  
  3. int LED = 13;
  4.  
  5. int x = 0;
  6.  
  7. void setup() {
  8.   // put your setup code here, to run once:
  9. pinMode (LED, OUTPUT);
  10. Wire.begin(4);
  11. Wire.onReceive(receiveEvent);
  12.  
  13. }
  14.  
  15. void receiveEvent(int bytes){
  16.   x = Wire.read();
  17. }
  18.  
  19. void loop() {
  20.   // put your main code here, to run repeatedly:
  21. if (x == 0) {
  22.   digitalWrite(LED, HIGH);
  23.   delay(540);
  24.   digitalWrite(LED, LOW);
  25.   delay(540);
  26. }
  27. if (x == 3){
  28.   digitalWrite(LED, HIGH);
  29.   delay(200);
  30.   digitalWrite(LED, LOW);
  31.   delay(200);
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement