Mixly-智能楼道灯
声控灯:
void setup(){
Serial
.begin(9600);
pinMode(8, OUTPUT
);
}
void loop(){
Serial
.println(analogRead(A3
));
if (analogRead(A3
) <= 100) {
digitalWrite(8,HIGH
);
}
else {
digitalWrite(8,LOW
);
}
}
人体红外检测灯:
void setup(){
pinMode(6, INPUT
);
Serial
.begin(9600);
pinMode(8, OUTPUT
);
}
void loop(){
Serial
.println(digitalRead(6));
if (digitalRead(6)) {
digitalWrite(8,HIGH
);
}
else {
digitalWrite(8,LOW
);
}
}
转载请注明原文地址: https://mac.8miu.com/read-501630.html