I have 2 Fio boards with Xbee series1 on top communicating (9600 baud) back an forth with "H" and "L" using the same code for both boards:
if(pin1 > pin2){
Serial.print('H');
delay(100);
digitalWrite(led10, LOW);
}else{
digitalWrite(led10, HIGH);
Serial.print('L');
delay(100);
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte == 'H') {
moteuravance(255, false, 0, true);
}else if (incomingByte == 'L') {
moteuravance(0, true, 255, false);
}
}
}
the function moteuravance(); is a command for two motors.
It works but not right a way. That is, when pin1 and pin2 values change there is, during 10-20 seconds, no effect and then, after a while, the motors begin to alternatively rotate in one sense and the other depending whether pin1 is larger or not than pin2.
Can somebody help me to understand what's going on? Is this something due the way the buffer is filling up?