Hi guys, l am trying to program my arduino uno, that is capable of sending continuous data and receive any data. Basically, l want my arduino to continuously send random numbers for example 35,250 to the Zigbee and Serial.print received data. The problem l have now is that l am able to continuously send random number but l am unable to receive any data. Do l have to do some sort of serial interrupt to stop the continuous loop or is there any other way of doing it? HELP! Below are the program l wrote.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3); // RX, TX
String rdata = "";
void setup()
{
Serial.begin(9600);
mySerial.begin(19200);
}
void loop() // run over and over
{
if (mySerial.available())
{
char inChar =(char)mySerial.read();
rdata += inChar;
if (inChar == '\n')
{
Serial.print(rdata.substring(26));
rdata = "";
}
}
int receiveData1 = random(45);
int receiveData2 = random(360);
mySerial.print("AT+UCAST:000D6F0001901473,");
mySerial.print(receiveData1);
mySerial.print(".");
mySerial.println(receiveData2);
Serial.print("AT+UCAST:000D6F0001901473,");
Serial.print(receiveData1);
Serial.print(".");
Serial.println(receiveData2);
}