Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Trying to turn on a led with Arduino and the xBee Api  (Read 302 times)
0 Members and 1 Guest are viewing this topic.
Honduras
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I am trying to turn on a led from the pc, and this will make an arduino to do the work
I am completely new with the API. I guess I am having troubles still don't know where.

This is my java code

Code:
xbee.open("/dev/ttyUSB0", 9600);
XBeeAddress16 destino = new XBeeAddress16(0x0013A200, 0x408B2E54);
                        int[] payload = new int[] { 90, 180 };
                        TxRequest16 tx = new TxRequest16(destino,payload);
                        TxStatusResponse status = (TxStatusResponse)xbee.sendSynchronous(tx);
                        if (status.isSuccess()) {
                            System.out.println("Se conecto");
                        }
                        else
                        {
                            System.out.println("No se conecto");
                           
                        }

This is my arduino code

Code:
XBee xbee = XBee();
uint8_t payload[] = { 1, 0 };

XBeeAddress64 address= XBeeAddress64(0x0013A200, 0x408b2E66);
ZBTxRequest tx = ZBTxRequest(address, payload, sizeof(payload));

TxStatusResponse txStatus = TxStatusResponse();
int BELL = 2;
void setup() {
  xbee.begin(9600);
  pinMode(BELL, OUTPUT);
  digitalWrite(BELL, HIGH);
}

void loop()
  {
    int signal;
    xbee.send(tx);
    if (xbee.readPacket(5000)) {                 
        if (xbee.getResponse().getApiId() == TX_STATUS_RESPONSE) {
           xbee.getResponse().getZBTxStatusResponse(txStatus);
             
           if (txStatus.getStatus() == SUCCESS) {
                digitalWrite(BELL, LOW);
                delay(10000);
                digitalWrite(BELL, HIGH);
           } else {
             
           }
        }     
    } else {
   
    }
    delay(5000);
  }
I am getting this error in my Java code. [ERROR] [com.rapplogic.xbee.examples.ApiAtExample] at command failed
java.lang.IllegalArgumentException: input value [1286656] is larger than a byte

Thanks for your time.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 124
Posts: 4577
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might be better asking that question on a Java forum.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: