Pages: [1]   Go Down
Author Topic: Toggling D0 value on XBee connected to Arduino  (Read 361 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am doing a simple home automation project using one Arduino and 2 XBee Series 1.

I am currently trying to toggle the D0 (output) value of the XBee attached to the Arduino using API packet (AT Command) through serial connection (SoftwareSerial).

The loop function has two parts:
- I change the D0 value from HIGH to LOW (this works)
- I change the D0 value from LOW to HIGH (this does not work)

So, the state of D0 stays at LOW the whole time.

Is there a restriction in terms of toggling data output pin values? What is the problem?

Code:
Code:
#include <SPI.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);


void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  delay(5000);
 
}


void loop() {

Serial.println("D0 açılıyor");

// ATD05 command is sent to local XBee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x05);
sendByte(0x08);
sendByte(0x00);
sendByte(0x44);
sendByte(0x30);
sendByte(0x05);
sendByte(0x7E);
  
delay(1000);

// ATWR command sent to local Xbee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x04);
sendByte(0x08);
sendByte(0x00);
sendByte(0x57);
sendByte(0x52);
sendByte(0x4E);

delay(1000);

// ATAC command is being sent to local Xbee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x04);
sendByte(0x08);
sendByte(0x00);
sendByte(0x41);
sendByte(0x43);
sendByte(0x73);



delay(5000);

Serial.println("D0 kapanıyor");

// ATD04 is being sent to local XBee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x05);
sendByte(0x08);
sendByte(0x00);
sendByte(0x44);
sendByte(0x30);
sendByte(0x04);
sendByte(0x7F);

delay(1000);

// ATWR is being sent to local XBee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x04);
sendByte(0x08);
sendByte(0x00);
sendByte(0x57);
sendByte(0x52);
sendByte(0x4E);

delay(1000);


// ATAC is being sent to local XBee
sendByte(0x7E);
sendByte(0x00);
sendByte(0x04);
sendByte(0x08);
sendByte(0x00);
sendByte(0x41);
sendByte(0x43);
sendByte(0x73);

delay(5000);
}




byte sendByte(byte val)
{
  byte length;
  length = mySerial.write(val);
  return val;
}


Thanks.
« Last Edit: March 05, 2013, 04:46:49 am by cigizoglu » Logged

Pages: [1]   Go Up
Jump to: