first commit
This commit is contained in:
1
code/hongwai/.pydio
Normal file
1
code/hongwai/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
a56befbf-09a4-4ddc-8367-86bd59e500a1
|
||||
23
code/hongwai/hongwai.ino
Normal file
23
code/hongwai/hongwai.ino
Normal file
@@ -0,0 +1,23 @@
|
||||
int irSensor = 0; // 连接红外传感器引脚
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(LED_BUILTIN, OUTPUT); //连接内置LED的引脚设置为输出模式
|
||||
pinMode(irSensor, INPUT); //连接人体红外感应模块的OUT引脚设置为输入模式
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
bool sensorReading = digitalRead(irSensor); //建立变量存储感应模块的输出信号
|
||||
if (sensorReading) {
|
||||
Serial.println("yes.....");
|
||||
digitalWrite(LED_BUILTIN, LOW); // 模块感应到人.输出高电平.点亮LED
|
||||
}
|
||||
else {
|
||||
Serial.println("no.....");
|
||||
digitalWrite(LED_BUILTIN, HIGH); // 无人状态保持LED关闭
|
||||
}
|
||||
|
||||
delay(2000);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user