Go Down

Topic: Toggling D0 value on XBee connected to Arduino (Read 427 times) previous topic - next topic

Mar 04, 2013, 05:50 pm Last Edit: Mar 05, 2013, 10:46 am by cigizoglu Reason: 1
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: [Select]

#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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy