尖叫怪
Language | English |
---|
目的可以感应人体活动,当有人经过时会发出怪兽吼叫的声音 原理设备
搭建硬件
软件调试代码说明
#define humanHotSensor 10
#define buttonPin 6
void pirDetector() {
// read the input pin:
humanHotState = digitalRead(humanHotSensor);
// print out the state of the button:
//Serial.println(humanHotState);
delay(1); // delay in between reads for stability
if(humanHotState) {
Serial.println("play sound.....");
audio_choose(1);// 2:health,1:noHealth
audio_play();
}
}
void updateButton() {
if(key_get(buttonPin,0)) {
delay(200);
on_off=!on_off;
}
if(statusChange!=on_off) {
statusChange=on_off;
if(on_off) {
Serial.println("pause");
audio_pause();
}
else {
Serial.println("pause");
audio_pause();
}
}
}
结果如果有人经过怪兽就会吼叫,触碰一下开关就会停止吼叫。 视频 |