void setup()
{
Serial.begin(9600);
}
void loop()
{
i = 0;
if(Serial.available()) // Check for availablity of data at Serial Port
{
while (i < 5)
{
Serial.write("sample"); // Printing the Serial data
Serial.flush();
delay (1000);
i = i + 1;
}
}
i = 0;
while (i == 0)
{
}
}
On UNO receiving side:
#include <SoftwareSerial.h>
SoftwareSerial UnoSerial(2,3);
// variables definition
String data;
void setup()
{
Serial.begin(9600);
UnoSerial.begin(9600);
}
void loop()
{
if (UnoSerial)
{
Serial.println("UnoSerial is listening!");
data = UnoSerial.readString();
Serial.println(data);
}
else
{
Serial.println("UnoSerial is not listening!");
}
}