风轻云淡愿君赏,消尽烦忧心亮敞。夏去秋来添衣裳,一声问候祝安康!

Wemos D1 继电器

int Relay = 2; 
 
void setup()
{
  pinMode(Relay, OUTPUT);
  Serial.begin(115200);
}
 
void loop()
{
  Serial.println("Plase input H or L:");
  char cmd;
  while(Serial.available() > 0){
    cmd = Serial.read();
    if (cmd == 'H')
    {
      Serial.println("Relay is HIGH");
      digitalWrite(Relay,HIGH);
    }
    else if(cmd == 'L'){
      Serial.println("Relay is LOW");
      digitalWrite(Relay,LOW);
    }
  }
  delay(5000); 
}

 

posted on 2021-08-13 21:26  荣林  阅读(176)  评论(0编辑  收藏  举报

导航