码丁实验室,一站式儿童编程学习产品,寻地方代理合作共赢,微信联系:leon121393608。
材料
arduino uno
蓝牙模块:HC-06
220V 1路继电器模块
嵌入式220V led装饰灯
全家福:
图片发自简书App

图片发自简书App
连接方案:

蓝牙开关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测试
如图:

图片发自简书App
注意:
1、接通电流后不要触摸继电器小心触电!!!
2、继电器接火线,不要接零线。
3、下载程序时要先拔掉蓝牙。