Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <XBee.h>
- // create the XBee object
- XBee xbee = XBee();
- uint8_t payload[] = { 0, 0 };
- // SH + SL Address of receiving XBee
- XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x408698be);
- ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
- ZBTxStatusResponse txStatus = ZBTxStatusResponse();
- int pin5 = 0;
- void setup() {
- Serial.begin(9600);
- xbee.setSerial(Serial);
- }
- void loop() {
- payload[0] = 0x34;
- payload[1] = 0x76;
- if (digitalRead(7) == HIGH){
- xbee.send(zbTx);
- delay(1000);
- }
- }
- #include <XBee.h>
- XBee xbee = XBee();
- XBeeResponse response = XBeeResponse();
- // create reusable response objects for responses we expect to handle
- ZBRxResponse rx = ZBRxResponse();
- ModemStatusResponse msr = ModemStatusResponse();
- void setup() {
- // start serial
- Serial.begin(9600);
- xbee.begin(Serial);
- }
- // continuously reads packets, looking for ZB Receive or Modem Status
- void loop() {
- xbee.readPacket();
- if (xbee.getResponse().isAvailable()) {
- // got something
- if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
- // got a zb rx packet
- // now fill our zb rx class
- xbee.getResponse().getZBRxResponse(rx);
- // I check both bytes (or)
- if (rx.getData(0) == 0x34 || rx.getData(0) == 0x76 ) {
- digitalWrite(8, HIGH);
- }
- }
- }
- }
- pinMode(8, OUTPUT);
- pinMode(7, INPUT);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement