-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ino
57 lines (52 loc) · 1 KB
/
main.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
#include<Wire.h>
#define SLAVE_ADDR 9
#define MASTER 6
byte arr2[]={};;
byte arr1[]={232,0,0};
void setup()
{
Wire.begin(SLAVE_ADDR);
//Wire.onRequest(requestEvent);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
// put your setup code here, to run once:
}
void receiveEvent()
{
int u = 0;
while(0<Wire.available())
{
byte x= Wire.read();
arr2[u]=x;
u=u+1;
}
Serial.println(arr2[0]);
Serial.println(arr2[1]);
Serial.println(arr2[2]);
}
//void requestEvent()
//{
//byte response[ANSWERSIZE];
//for(byte i=0;i<ANSWERSIZE;i++)
//{
//response[i]=(byte)answer.charAt(i);
//}
//Wire.write(response,sizeof(response));
//}
void loop()
{
int i = 0;
while(0<Wire.available())
{
if( arr1[i]!=arr2[i])
{
Wire.beginTransmission(MASTER);
Wire.write(13);
Wire.write(14);
Wire.write(15);
Wire.endTransmission();
}
delay(2000);
}
}
// put your main code here, to run repeatedly: