自制一个PIR人体热感报警器
PIR简介下面学一个简单的报警器,主控用attiny85
//---made by gada888---2018-08-30---
void setup() {
pinMode(1, OUTPUT);
pinMode(0, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int sensorValue = digitalRead(0);
if(sensorValue==1)
{
digitalWrite(1, HIGH);
delay(3000);
}
else
{
digitalWrite(1, LOW);
}
delay(1); // delay in between reads for stability
}
再来个个人原创的报警声音放大版的。
//---made by gada888-----
const int pirPin = 0; // PIR sensor
const int buzzer = 1; // buzzer
int alarmLength = 40;
// the setup routine runs once when you press reset:
void setup() {
pinMode(1, OUTPUT);
pinMode(0, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
int sensorValue = digitalRead(0);
if(sensorValue==1){
while(alarmLength >= 0){
alarmLength--;
alarmOn(100);
}
alarmLength = 40;
}
else {
alarmOff();
}
delay(1); // delay in between reads for stability
}
void alarmOn(int delayMs){
analogWrite(buzzer, 100);
delay(delayMs);
analogWrite(buzzer, 0);
delay(delayMs);
}
void alarmOff(){
analogWrite(buzzer, 0);
}
https://v.youku.com/v_show/id_XMzgwMzQxOTcyNA==.html?spm=a2h3j.8428770.3416059.1
沙发 板凳 地板 地下室 attiny85要用专用的烧录器,其实针脚一换,可以上传程序到arduino上 电源控是LP2950-5V。忘写了 喇叭是3-24V那种,5v声音也不小了。 用attiny85是为了简单便携 楼主占楼的能力炒鸡厉害 这个在米司齐里面可以运行吗
页:
[1]