September 2017
Intermediate to advanced
206 pages
4h 34m
English
The next step is to develop a program. We'll write a sketch program for Arduino. In this case, we attach our XBee to the Arduino through an XBee shield. This means that the XBee connects to the Arduino via serial pins (digital pin 0 and 1). We'll use the serial object to communicate with the Arduino.
Here is the complete sketch program:
void setup() {
// start serial
Serial.begin(9600);
while (!Serial) ;
// Arduino Leonardo
// Serial1.begin(9600);
// while (!Serial1) ;
}
void loop() {
//Serial1.println("hello"); // Leonardo
Serial.println("hello");
delay(1000);
}
Save this program as ArduinoXBee. This program will send the message hello. If you use Arduino Leonardo, uncomment the commented section because Arduino ...
Read now
Unlock full access