最新消息:

arduino 蓝牙 继电器 开关灯

Arduino 少儿编程 2066浏览 0评论

材料

arduino uno
蓝牙模块:HC-06
220V 1路继电器模块
嵌入式220V led装饰灯

全家福:
arduino 蓝牙 继电器 开关灯
图片发自简书App

连接方案:

arduino 蓝牙 继电器 开关灯
蓝牙开关220V电灯.jpg

程序:

void setup() {
Serial.begin(9600);// put your setup code here, to run once:
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
}

void loop() {
  while(Serial.available())
  {
    char c = Serial.read();
    if(c == 'A'){
      digitalWrite(8,LOW);
    }
    if(c == 'B'){
      digitalWrite(8,HIGH);
    }// put your main code here, to run repeatedly:
  }
}

手机APP 可以APP INVENTOR自制,也可以下载“蓝牙串口”APP测试
如图:

arduino 蓝牙 继电器 开关灯
图片发自简书App

注意:

1、接通电流后不要触摸继电器小心触电!!!
2、继电器接火线,不要接零线。
3、下载程序时要先拔掉蓝牙。

您必须 登录 才能发表评论!