Tak Tak Tak
xBee doorbell

Working with xBee, configuration.
in Building Wireless Sensitive Networks, ch 1-3.
Pg 37.
Using X-CTU in PC, set the xBee’s Pan id.
Also set which is Collector or Receiver.
Pg 51.
Using CoolTerms, to set receiver/communicator’s destination.
ATID -> PAN ID, should be 4 digits, ie 2105
ATDH -> destination, ie 0013A200
ATDL -> destination, ie 4089D8e8

Here’s the exercise in Ch3.
exercise done with Phil Groman

The Communicator
#define VERSION “1.00a0″
int BUTTON = 2;
int LED1 = 11; //added LED for feedback, int LED conflicts in Arduino 1.0
void setup() {
pinMode(BUTTON, INPUT);
pinMode(LED1, OUTPUT);
Serial.begin(9600);
}
void loop() {
// send a capital D over the serial port if the button is pressed
if (digitalRead(BUTTON) == HIGH) {
Serial.print(‘D’);
delay(10); // prevents overwhelming the serial port
}
// if a capital K is received back, light the feedback LED
if (Serial.available() > 0 ) {
if (Serial.read() == ‘K’) {
digitalWrite(LED1, HIGH);
}
}
// when the button is released, turn off the LED
if (digitalRead(BUTTON) == LOW) {
digitalWrite(LED1, LOW);
}
}


The Receiver
#define VERSION “1.00a0″
int BELL = 5;
void setup() {
pinMode(BELL, OUTPUT);
Serial.begin(9600);
}
void loop() {
// look for a capital D over the serial port and ring the bell if found
if (Serial.available() > 0) {
if (Serial.read() == ‘D’) {
//send feedback that the message was received
Serial.print(‘K’);
//ring the bell briefly
digitalWrite(BELL, HIGH);
delay(10);
digitalWrite(BELL, LOW);
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>