Hello Graynomad, thanks for your help ![]()
I have changed my program as you suggested. I have included a null terminator and used strcmp but still the output is same ![]()
Do you see any logical error in my code?
int ledPin = 13;Â Â Â Â Â
const int maxLength=140;Â Â Â Â //maximum length for textbox data
char char_in[maxLength];Â //Create a buffer to input all incoming data
int i=0;
void setup() {
 pinMode(ledPin, OUTPUT); //Configure pins as output
 Serial.begin(9600);   //begin serial communication
}
void loop() {
 if (Serial.available() > 0)  //Is any serial data available
 {
  for( i=0;i<maxLength && Serial.available();i++)
  {
   char_in[i] = Serial.read();
 Â
  }
Â
 char_in[i+1]='\0';
  if (!strcmp(char_in,"on1"))
  {
   digitalWrite(ledPin,HIGH);
  }
  else if(!strcmp(char_in,"of1"))
  {
   digitalWrite(ledPin,LOW);
  }
  else
  {
   Serial.print(char_in);
  }
 }
Â
}