Garage Bugler Alarm - Arduino Nano / Pi Pico, PIR sensor and magnetic door switch.
HTML-код
- Опубликовано: 13 сен 2024
- I made alarm with an Arduino and it stopped downloading at the end so had to switch to a Pi Pico using Arduino IDE and C+ for my first time. I prefer C+ to Python so I will be using this in future.
LOST ME THE SECOND MUSIC STARTED.
you aint got a garage mate lol well not last time i was over . i got something i need you to look at 8 channel mixer that wont power up could be any thing i have no multimeter since the lcd died lol iots old style capacirtors in there lol
Workshop then lol. Have you not been in the Workshop? Might be easy if it`s got no power.
int n=0;
int alarm_mode=0;
int door=0;
int on_off=0;
int pir=0;
int exit_time=0;
int entry_time=0;
int intruder=0;
int alarm_time=0;
void setup() {
pinMode(8, INPUT); // ON/OFF SWITCH
pinMode(9, OUTPUT); // BUZZER
pinMode(10, INPUT); // DOOR MAGNETIC SWITCH
pinMode(11, INPUT); // PIR SENSOR
pinMode(12, OUTPUT); // ALARM RELAY
pinMode(13, OUTPUT); // LED
digitalWrite(9, LOW); // SET BUZZER LOW = OFF
digitalWrite(12, LOW); // ALARM RELAY DEFAULT HIGH = OFF
digitalWrite(13, LOW); //SET THE LED LOW = OFF
delay(1000);
}
void loop() {
on_off=digitalRead(8);
delay(4);
door=digitalRead(10);
delay(4);
pir=digitalRead(11);
intruder=0;
if(pir == HIGH){
intruder=1;
}
if(door == LOW){
intruder=1;
}
if (intruder == 0){digitalWrite(13, LOW);}
if (intruder == 1){digitalWrite(13, HIGH);}
if (on_off == LOW){
alarm_mode=0;
digitalWrite(12, LOW);
noTone(9);
}
if (alarm_mode == 0 && on_off == HIGH){
alarm_mode=1;
exit_time=6000; // 60 seconds
}
if (alarm_mode == 1){ // ALARM SET AND WAITING 60 SECONDS TO GET OUT.
exit_time=exit_time-1;
if (n==0){tone(9, 1000);}
if (n==20){noTone(9);}
if (exit_time == 0){
alarm_mode=2;
}
}
if (alarm_mode == 2){ // ALARM SET. WAITING FOR AN INTRUDER.
noTone(9);
if (intruder == 1){
alarm_mode=3;
entry_time=3000; // 30 seconds
}
}
if (alarm_mode ==3){ // Coming into the garage and the alarm enter timer is activated.
if (n==0){tone(9, 800);}
if (n==50){noTone(9);}
entry_time=entry_time-1;
if (entry_time == 0){
alarm_mode=4;
alarm_time=1000;
}
}
if (alarm_mode == 4){
noTone(9);
digitalWrite(12, HIGH); // ALARM RELAY ACTIVATED.
alarm_time=alarm_time-1;
if (alarm_time == 0){
digitalWrite(12, LOW);
alarm_mode=5;
}
}
if (alarm_mode ==5){ // Alarm has been activated and now warns me of an intruder has been in.
if (n==0){tone(9, 1500);}
if (n==5){noTone(9);}
}
n=n+1;
if(n >= 100){
n=0;
}
delay(2);
}
I also hate buglers - that nasty sound, not a even as cool as real trumpet, let alone a fluegelhorn - playing some throwback screeching sounds. Bugles suck
Lol when I typed burgler the spell checker put a red line under it so I thought it was wrong. I`m not good at spelling. I gave up with English as it`s not that logical at school. I was programming at 12 year old so my mind was more interested in that. Great comment. Made me laugh mate.