-
Notifications
You must be signed in to change notification settings - Fork 0
/
receive.ino
43 lines (39 loc) · 846 Bytes
/
receive.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
#include <SoftwareSerial.h>
#define rxPin 3
#define txPin 2
#define ledPin 13
SoftwareSerial xbee = SoftwareSerial(rxPin, txPin);
//int count = 0;
void setup(){
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(ledPin, OUTPUT);
xbee.begin(9600);
Serial.begin(9600);
Serial.println("Starting XBee Communication");
}
int count = 0;
void loop(){
//Serial.println("Waiting for XBe");
//if (x != -1)
//if (count % 10 == 0) Serial.println();
if (xbee.available()) {
char x = xbee.read();
Serial.println(x);
if (x=='5'){
Serial.println("Replying 6");
xbee.print('6');
count++;
}
else{
Serial.println("Replying 9");
xbee.print('9');
count++;
}
Serial.print("counter = ");
Serial.println(count);
}
//++count;
//Serial.println(rec);
//delay(1500);
}