I'm writing this a small code for my project - Its a communication between XCTU and Arduino with Xbee module
Here is the code that I have so far, basically, when type in "1" or "2" in the XCTU terminal, the Arduino will activate one of the output to light up the LED,
but I want to change this code to be able to read more than a character on the terminal, for example, when I type in "ONE" or "TWO" in the XCTU terminal, the Arduino will activate the output. Can someone please help me on the coding???
void setup()
{
Serial.begin(9600); //initialize serial
pinMode(7, OUTPUT); //set pin 7 as output Yellow LED
pinMode(6, OUTPUT); //set pin 6 as output Red LED
}
void loop()
{
while(Serial.available())
{ //is there anything to read?
char getData = Serial.read(); //if yes, read it
if(getData == '1'){
Serial.println(""); // prints another carriage return
digitalWrite(7, HIGH);
Serial.print("YELLOW LED ON ");
Serial.println(""); // prints another carriage return
delay(2000);
digitalWrite(7, LOW);
Serial.print("YELLOW LED OFF ");
Serial.println(""); // prints another carriage return
}else if(getData == '2'){
Serial.println(""); // prints another carriage return
digitalWrite(6, HIGH);
Serial.print("RED LED ON ");
Serial.println(""); // prints another carriage return
delay(2000);
digitalWrite(6, LOW);
Serial.print("RED LED OFF ");
Serial.println(""); // prints another carriage return
}
}
}