This should be a simple one for anyone but me...
What I'm trying to do:
Send data from the Due to the Mega via Serial, and show that the data is moving by having the Due send a $ chr to turn an LED on the Mega on, then 2 seconds later, send a # chr to turn it off. LED is on Pin 8 of the Mega.
The problem:
This setup works, for the most part. It seems it is missing communication because the LED does not always toggle on, or off after 2 seconds. Sometimes it does, sometimes it doesn't.
Hardware:
Arduino Due Pin 0 (RX) TO Mega pin 1 (TX)
Arduino Due Pin 1 (TX) TO Mega pin 0 (RX)
Arduino Due GND to Mega GND
Arduino Due code:
void setup(){
Serial.begin(115200);
}
void loop(){
Serial.print("$");
delay(2000);
Serial.print('#');
delay(2000);
}
Arduino Mega code:
void setup(){
Serial.begin(115200);
pinMode(8, OUTPUT);
}
void loop(){
delay(1);
if(Serial.read() == '
Any thoughts?){
delay(1);
digitalWrite(8, HIGH);
}
delay(1);
if(Serial.read() == '#'){
delay(1);
digitalWrite(8, LOW);
delay(1);
}
delay(1);
}
Any thoughts?