Trying to link two arduino together using TX/RX. I have 3 Uno and 2 Mega. No combination works. I even tried other peoples script; AddFive and Flash_the_Led. The loopback test of grounding the reset pin even works without tying the Tx and Rx pins together(?). I even deleted the 1.0.6 IDE and loaded the 1.8.3 IDE. I even reloaded the Uno and Mega drivers from Microsoft update. Nothing helps. I am using 7 in jumpers. Gnd to Gnd, Tx to Rx, Rx to Tx. Do I need to add a Library to the IDE?
It appears to be related to his Christmas lights project already posted about. :
I do have a Christmas project in works, but I'm breaking the task down to levels I can deal with. Current task is to get one Arduino Mega to talk to Arduino Uno. Here is an example. From Arduino Serial Monitor on PC enter a value say 1. Usb from PC to Mega. Out of Mega on TX3 to Uno RX0. Pin 13 blinks once. Data Passed thru Mega !! If I enter 2, Uno pin 13 blinks twice. The blink isn't important, the data pass thru is the goal. This seems simple, but it has me stumped.
I am assuming I have to get serial to work before I can start using RS485 cards that are on order.???
//Flash_the_LED_Tx
/* Transmitter
For more details see: http://projectsfromtech.blogspot.com/
Connect the Tx pin of this board to the Rx of the board running Flash_the_LED__Tx.ino
Connect the Grounds of the two boards
Read integer value from Serial Monitor
Transmit that value to the Rx board
*/
// I modified this to be able to use my Mega
int val = 0;
int incoming = 0;
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
Serial.println("Serial Monitor Connected"); //Is not an integer so it won't interfere
}
void loop()
{
incoming = Serial.available();
while (incoming == 0) //keep checking until something is available
{
incoming = Serial.available();
}
Serial.print("Received value... Transmitting: ");
val = Serial.parseInt(); //Reads integers as integer rather than ASCI. Anything else returns 0
//Note that this is a user input via the Serial Monitor
Serial.println(val); //This is being sent to the Rx board
Serial3.write(val);
}
//Flash_the_LED_Rx
/* Receiver
For more details see: http://projectsfromtech.blogspot.com/
Connect the Tx pin of this board to the Rx of the board running Flash_the_LED__Tx.ino
Connect the Grounds of the two boards
Receive an integer value over the serial and
flashes the LED the appropriate number of times
*/
int val = 0;
const int led = 13;
int incoming = 0;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
incoming = Serial.available();
while (incoming == 0) //Keep checking until there is something available
{
incoming = Serial.available();
}
val = Serial.parseInt(); //Reads integers as integer rather than ASCI. Anything else returns 0
for (int i = 0; i < val ; i++) //Flash the LED the appropriate number of times
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
val = 0;
}
Thank you Delta_G. You put me back on track. Since I can't say what I was expecting, I wrote a new code to define what I'm expecting. Turn on chan 1, turn off chan 1, turn on chan 2, turn off chan 2, etc thru chan 32. Now I know what I'm expecting!!! I feed to to my receiver Uno. the wrong lights came on, but in the right sequence. So I added a frame start header symbol "!". The receiver reset the counter every time the header comes in. Now my lights are not only in sequence, but in the right time.