Alrighty. Heres the codes and links, sry about that, i took it for granted that people would know what i was talking about. Hope ya could help me fix it, been on it for a couple of fruitless days already
http://code.google.com/p/xbee-arduino/ ← library.
http://www.liquidware.com/antipasto_arduino_ide ← IDE i’m using
http://www.liquidware.com/shop/show/TSL/TouchShield+Slide ← Touch Shield Slide
http://www.sparkfun.com/commerce/product_info.php?products_id=8691 ← Xbee type i am using
http://www.sparkfun.com/commerce/product_info.php?products_id=666 ← arduino Duemilanove
and finally
http://www.sgbotic.com/index.php?dispatch=products.view&product_id=52 ← Xbee Shield
the codes for the sketch are below. for running on arduino to view output i’ll uncomment out the Serial() codes and comment out text() codes and vice versa.
#include <XBee.h>
XBee xbee = XBee();
// //Serial high
uint8_t shCmd = {‘S’,‘H’};
// //Serial low
uint8_t slCmd = {‘S’,‘L’};
// association status
uint8_t assocCmd = {‘A’,‘I’};
AtCommandRequest atRequest = AtCommandRequest(shCmd);
AtCommandResponse atResponse = AtCommandResponse();
void setup() {
xbee.begin(9600);
// start soft //Serial
//Serial.begin(9600);
// Startup delay to wait for XBee radio to initialize.
// you may need to increase this value if you are not getting a response
delay(10000);
}
void loop() {
// get SH
sendAtCommand();
// set command to SL
atRequest.setCommand(slCmd);
sendAtCommand();
// set command to AI
atRequest.setCommand(assocCmd);
sendAtCommand();
// we’re done. Hit the Arduino reset button to start the sketch over
}
void sendAtCommand() {
//Serial.println(“Sending command to the XBee”);
text(“Sending command to the XBee”, 10, 10);
// send the command
xbee.send(atRequest);
// wait up to 5 seconds for the status response
if (xbee.readPacket(5000)) {
//Serial.println(“Recieved!”);
text(“Recieved!”);
// should be an AT command response
if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
xbee.getResponse().getAtCommandResponse(atResponse);
if (atResponse.isOk()) {
//Serial.print(“Command [”);
//Serial.print(atResponse.getCommand()[0]);
//Serial.print(atResponse.getCommand()[1]);
//Serial.println("] was successful!");
text(“Command [”, 10,20);
text((atResponse.getCommand()[0]), 10, 30);
text((atResponse.getCommand()[1]), 10, 40);
text("] was successful!", 10, 50);
if (atResponse.getValueLength() > 0) {
//Serial.print("Command value length is ");
//Serial.println(atResponse.getValueLength(), DEC);
//Serial.print("Command value: ");
text("Command value length is ", 10, 60);
text((atResponse.getValueLength(), DEC), 10, 70);
text("Command value: ", 10, 80);
for (int i = 0; i < atResponse.getValueLength(); i++) {
//Serial.print(atResponse.getValue(), HEX);
_ text((atResponse.getValue(), HEX), 10, 90);_
* text(" ", 10, 100);*
* }*
* //Serial.println("");*
* text("", 10, 110);*
* }*
* }*
* else {*
* //Serial.print("Command return error code: ");*
* //Serial.println(atResponse.getStatus(), HEX);*
* text("Command return error code: ", 10, 120);*
* text((atResponse.getStatus(), HEX), 10, 130);*
* }*
* } else {*
* //Serial.print("Expected AT response but got ");*
* //Serial.print(xbee.getResponse().getApiId(), HEX);*
* text("Expected AT response but got ", 10, 140);*
* text((xbee.getResponse().getApiId(), HEX), 10, 150);;*
* } *
* } else {*
* // at command failed*
* if (xbee.getResponse().isError()) {*
* //Serial.print("Error reading packet. Error code: "); *
* //Serial.println(xbee.getResponse().getErrorCode());*
* text("Error reading packet. Error code: ", 10, 160); *
* text((xbee.getResponse().getErrorCode()), 10, 170);*
* }*
* else {*
* //Serial.print(“No response from radio”); *
* text(“No response from radio”, 10, 180); *
* }*
* }*
}
Thanks.