Friday, 15 March 2019

Serial Communication

Node MCU :Serial Communication code for arduino IDE

long  x;
void setup()
{
  x = ' ';
Serial.begin(9600);
pinMode(2, OUTPUT);

}


void loop()
{

    if (Serial.available() == 1) 
    {
      x = Serial.read();
      if (x == 'a') 
      {
        Serial.println("LED ON");
        digitalWrite(2,LOW);

      } 
     else if (x == 'b')
     {
        Serial.println("LED ON");
        digitalWrite(2,HIGH);
      }

    }


}

Node MCU : Serial Communication code for TUNIOT



No comments:

Post a Comment