Hello everybody,
I sketched this simple code to send strings from an android telnet client application to arduino mega through ESP8266 wireless module.
The strings sent are converted to integers and correspond to leds pins, it works great lighting the leds from the mobile but when i use the Serial3.println command it doesn't show the print message on mobile and instead it shows it on the serial monitor !
Here is the code,
int r[3], f = -2;
String y = "";
void setup(){
Serial.begin(9600);
Serial3.begin(9600);
Serial3.setTimeout(100);
pinMode(23,OUTPUT);
pinMode(24,OUTPUT);
pinMode(25,OUTPUT);
}
void loop() {
String IncomingString = "";
while (Serial3.available())
{
IncomingString=Serial3.readString();
Serial.println("Received String: " + IncomingString);
f++;
y = IncomingString.substring(11,12);
r[f] = y.toInt();
}
if (r[f] == 1){
digitalWrite(23,HIGH);
Serial3.println("led #1 on");
}
if (r[f] == 2){
digitalWrite(24,HIGH);
Serial3.println("led #2 on");
}
if (r[f] == 3){
digitalWrite(25,HIGH);
Serial3.println("led #3 on");
}
}