-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm3_s2.ino
73 lines (58 loc) · 1.24 KB
/
m3_s2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<Wire.h>
int LED1=12;
int LED2=13;
int b;
int wait=2000;
#include <LiquidCrystal.h>
LiquidCrystal lcd(10, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
pinMode(LED1,OUTPUT); // put your setup code here, to run once:
pinMode(LED2,OUTPUT);
Serial.begin(9600);
}
void receiveEvent(int bytes)
{
b = Wire.read();
}
int c=0;
void loop()
{
if (c==0)
{
delay(200);
c++;
}
Wire.begin(8);
Wire.onReceive(receiveEvent);
//receiveEvent(x);
Serial.print("y recieved to b");
Serial.println(b);
lcd.setCursor(0,0);
lcd.print(b);
if (b == 0) {
digitalWrite(LED1, HIGH);
delay(wait);
digitalWrite(LED1, LOW);
delay(wait);
Serial.println("b done0");
}
else if (b == 1) {
digitalWrite(LED2, HIGH);
delay(wait);
digitalWrite(LED2, LOW);
delay(wait);
Serial.println("b done1");
}
else {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
delay(wait);
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
delay(wait);
Serial.println("b done else");
}
lcd.clear(); // put your main code here, to run repeatedly:
}