Hello,
This is probably a newbie question but I would like your help as I have been strugling for over a week. I am trying to send a 0/1 from a Fio over an Xbee S1 to an Arduino Uno with a Xbee shield to turn on LED 13.
Ofcourse I have already setup xbee's and I have double check that they communicate to each other.
I managed to make it work with USB explorer connected to my PC and coolterm. When I type 0, led is off and when I type 1, led is ON.
Here is the code I am using to UNO side:
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(13, OUTPUT);
// blink twice at startup
digitalWrite(13, LOW);
delay(1000);
digitalWrite(13, HIGH); // first blink
delay(50);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH); // second blink
delay(50);
digitalWrite(13, LOW);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
if(incomingByte == '0'){
digitalWrite(13, LOW);
}else if(incomingByte == '1'){
digitalWrite(13, HIGH);
}
// say what you got:
Serial.print("UNO received: ");
Serial.write(incomingByte); // Arduino 1.0 compatibility
Serial.write(10); // send a line feed/new line, ascii 10
}
}
I tried to take it a step further. I wanted to achieve the same thing from a Fio v3 (it has a Xbee socket) using the serial monitor.
here is the code at Fio's side am using but nothing happens
#include <SoftwareSerial.h>
SoftwareSerial xBee = SoftwareSerial(2,3);
void setup() {
Serial.begin(9600);
xBee.begin(9600);
Serial.println("Sending...");
}
// the loop routine runs over and over again forever:
void loop() {
xBee.print(1);
delay(1000); // delay in between reads for stability
xBee.print(0);
}
Please forgive me but I don't know where to start from. What is missing? What am doing wrong?
Any help or guidance would be much apreciated.
thanks in advance