Hello, I just received my Xbee Relay Shield robotshop.com/en/dfrobot-rel … duino.html I used the example code in the documentation and the relays work perfectly. However, I am not very good at writing code yet, and I tried to alter the code so that I could energize the relays wirelessly. I would like to be able to turn on any combination of relays with toggle switches. So far I haven’t had much luck. At one point I did get relay 1 to turn on but it would not turn off. Oddly enough when I turned on relay 2 it turned off relay 1 at the same time it turned on # 2. I tried to write a totally different code. I had the four relays operating independently. The problem was I had a delay in the code which turned them on and off so fast I was afraid they’d be damaged. Has anybody had any luck with code that would accomplish what I am looking for?
To confirm, you have the shield, an Arduino and an XBee module? Are you using an XBee module connected to a USB to XBee board to send commands?
Before going wireless, understand the code used to activate and deactivate each relay - create a code where you can use the Arduino serial terminal to write a letter (or number), press enter, and the relay will activate, and then something else to deactivate.
Once you have this working (via USB), expand the code to include all four relays, then go wireless.
if(Serial.available() > 0) {
if(Serial.read() ‘B’) {
digitalWrite(BUTTON, HIGH);
}
[/code]
on the arduino with the relay shield. I used pin 10 which was turning relay 4 on and off. It was only when I tried to add more buttons and relays when I started to run into trouble.