Create a Budget DIY Intruder Alarm With an ATTINY 85
by scanos in Circuits > Arduino
622 Views, 4 Favorites, 0 Comments
Create a Budget DIY Intruder Alarm With an ATTINY 85
The idea is to take an old speaker and generate an intruder alarm from an ATTINY85 when a signal is detected.
A button is used to simulate sensor triggers but PIRs etc can be used instead.
Supplies
ATTINY85
Old speaker
Breadboard
9 volt battery
LM7805 - 9volt to 5 volt convertor
Dupont cables
Button
Programming the ATTINY85
To program the ATTINY85, follow the instructions on https://www.instructables.com/15-Dollar-Attiny85-...
and use this code in the Arduino IDE
/* TinyTone for ATtiny85 */ //clock 1mhz internal //usbasp programmer // Notes const int Note_C = 239; const int Note_CS = 225; const int Note_D = 213; const int Note_DS = 201; const int Note_E = 190; const int Note_F = 179; const int Note_FS = 169; const int Note_G = 159; const int Note_GS = 150; const int Note_A = 142; const int Note_AS = 134; const int Note_B = 127; int Speaker = 1; void setup() { pinMode(Speaker, OUTPUT); } void loop() { playTune(); delay(10); } void TinyTone(unsigned char divisor, unsigned char octave, unsigned long duration) { TCCR1 = 0x90 | (8-octave); // for 1MHz clock // TCCR1 = 0x90 | (11-octave); // for 8MHz clock OCR1C = divisor-1; // set the OCR delay(duration); TCCR1 = 0x90; // stop the counter } // Play a scale void playTune(void) { TinyTone(Note_C, 4, 50); //TinyTone(Note_D, 4, 500); //TinyTone(Note_E, 4, 500); //TinyTone(Note_F, 4, 500); TinyTone(Note_G, 4, 50); //TinyTone(Note_A, 4, 500); //TinyTone(Note_B, 4, 500); //TinyTone(Note_C, 5, 500); }
Instructions
After programming the ATTINY85, the steps are as follows:
1. Connect Pin 3 LM7805 to VCC Attiny85 and Pin 2 to Gnd Attiny85
2. Connect Pin 1 LM7805 to +ve 9V battery and Pin 2 LM7805 to -ve 9V battery
3. Add +ve terminal speaker to pin 1 Attiny85 and -ve terminal speaker to Gnd Attiny85 (via Dupont cable)
You can also add a button by changing step 3 to
3. Add +ve terminal speaker to pin 1 Attiny85 and -ve terminal speaker to button pin, then connect diagonally opposite button pin to Gnd Attiny85 (via Dupont cable)
Next Steps
A variety of different sensors may be used to trigger the circuit , including PIR , Ultrasonic and manual switches. The output from the speaker may be amplified using an LM386 module widely available on E-bay.
Please ensure that you adhere to strict electrical safety guidelines, i.e.
1. Seek guidance from a person competent in electrical safety such as a qualified electrician.
2. Use low voltage.
3. Ensure that all connections are secure, cables are intact and do not lead to electrical shorts.
4. Etc