The code below is the receiver side of my xbee/Arduino experiment. One part of the code turns on a noise maker circuit I constructed, and the other turns on the on-board LED on pin13. The LED flickers like a flame, and it seems like the code my be using too much processing power or something. Please take a look and let me know what you think.
I'm not really sure what you're asking, but The xbees are running 9600 and everything else is too. One other clue, is that when I look at the 1s and 2s on my serial monitor, it usually freezes up.
Magician:
I'm not sure if it's right to use two Serial.Read, it create instability as first Serial.Read will
discard symbol that come in not right time-spot.
There is edited version :
void loop()
{
if(Serial.available() > 0)
{
int val1 = Serial.read();
Okay, so you send a 1, the LED turns on - anything else turns it off, and 2 turns it off the 1/10 second of delay too.
Further, you have no debounce on your button presses on the send side, so as you push button 1 you will send out 01010101011111 until it settles, and when you release it will do the same 111101010100000. But since you send button 2 info at the same time, it turns off almost as soon as it turns on.
So the poor LED really has no chance to turn on & stay on.
What would help is to have it turn off with a '3' for example, instead of "not 1".
CrossRoads:
Okay, so you send a 1, the LED turns on - anything else turns it off, and 2 turns it off the 1/10 second of delay too.
Further, you have no debounce on your button presses on the send side, so as you push button 1 you will send out 01010101011111 until it settles, and when you release it will do the same 111101010100000. But since you send button 2 info at the same time, it turns off almost as soon as it turns on.
So the poor LED really has no chance to turn on & stay on.
What would help is to have it turn off with a '3' for example, instead of "not 1".
I tried the 3 off and it wouldn't work at all. I keep the button pushed on the LED13 button and it still flashes like a flame.
No I didn't change the on to be 3, but I did change the off to be three. I posted that it didn't work, but afterwards, I re-uploaded it and pressed rest then it did. I fixed the problem though, it needed a delay of one second after the Serial.print('1') on the sender side. That fixed it, and I really don't know why, but it did. Thanks for all the help, it's nice to know you have all these friendly people on here to help.