Project Summary:
Arduino to send API Frames to Xbee that will either open or close a city water valve, then turn the supply voltage on or off to complete the process. I currently have the circuit working between the Xbee coordinator and router perfectly. I have the Digital (DIO4, DIO5) pins of the Coordinator setup with the same pins of the Router. I now need to get the Arduino to send API packets to the Xbee Coordinator using serial communications (pin2, pin3). I believe that I am close, but I am getting an error "expected "}" before numeric constant" when the upload gets to the byte Valve_OPEN4[] . I copied the frames out of XCTU and converted them to hex. It has to be something dumb, that I am doing.... or not doing!!!
Thanks in advance for any assistance.
// Write API Frame packet from Arduino to Xbee
// http://forum.arduino.cc/index.php?topic=119463.0
// include <Wire.h>
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
byte pinState = 0;
// Frame for 'Valve' Open or Valve Close
byte Valve_CLOSE4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5E};
// //////// the following line is the error line ///////////
byte Valve_OPEN4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5D};
// Frame for 'Valve' Power "ON" or "OFF"
byte Valve_Power_ON5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5E};
byte Valve_Power_OFF5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5F};
void setup()
{
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(19200);
// Serial.begin(19200);
}
void loop()
{
mySerial.write(Valve_OPEN4,20);
delay(3000);
mySerial.write(Valve_CLOSE4,20);
delay(3000);
////////////////////////////////////////////////////////
/////// RESET VALVE POWER TO OFF WHEN VALVE IS OPENED OR CLOSED /////////////////////
//////////////////////////////////////////////////////
}