I wish to send serial data from an Arduino Uno to an Arduino Nano via the available UART port.
On reception of data at the Nano end I have to check whether the data matches to "a" or "b". If it does, I have to send data back to the Uno.
I have used the following Code on the Nano side:
void GMP_OutputSerial(void)
{
if(Serial.available()) // Check if serial data is avaiable
{
unSerialAvailable = Serial.read(); // Read the data if serial data is available
if(unSerialAvailable == 'A' || unSerialAvailable == 'B' || unSerialAvailable == 'a' || unSerialAvailable == 'b') // Proceed only if available data is equal to A or B
{
/*
if(g_stSensorParms.stAppParms.unFinalDistance > 80 || g_stSensorParms.stAppParms.unFinalDistance < 0)
{
Serial.println("Distance: Out of range");
}
else
{
*/
Serial.print("Distance: "); // Output Distance text on the serial monitor
Serial.println(g_stSensorParms.stAppParms.unFinalDistance); // Output the actual distance on the serial monitor
}
}
}
On the Uno side:
void loop()
{
Serial.write(a);
delay(1);
}
However, I see no communication happening. Power to the both the boards comes from an external supply = 5V.
TX line of Uno is connected to RX line of Nano and vice versa.
What am I doing wrong?