I have the problem with compare incoming byte from telnet with string on this below code . How to correct them? Anyone can help me to make it right please?
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar =client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
if (thisChar = "turn on") {
Serial.println("Switch On");
}
if (thisChar = "turn off") {
Serial.println("Switch off");
}
else {
Serial.println("You key a wrong command, PLS key a correct one");
}
char thisChar =client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
if (thisChar = "turn on")
Read a single character then compare it with a string of several characters. Will that work I wonder ?
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
if (thisChar = "turn on")
Read a single character then compare it with a string of several characters. Will that work I wonder ?
See http://gammon.com.au/serial
Thank you UKHeliBob But what functions will you recommend me to use for reading a single character then compare it with a string of several characters?