This project is a twist on the usual alarm system that flashes lights and beeps after a certain range. This project prints to the serial monitor that the person or thing is getting closer and closer and should stop. The green LED lights up and the monitor prints to the user that it is a safe distance and should stay there. When the user is closer the blue LED lights up and the monitor prints to the user that it has gone far enough and is warned. After that, the red LED lights us and the monitor prints off that the alarm system was activated and buzzes the alarm.
Here is what you'll need
1 x breadboard
1 x Arduino Uno
1 x ultrasonic sensor
1 x active buzzer
3 x led
3 x 220 ohm resistors
several jumper wires.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Step 1: Add the 3 LEDs
First just to get it out of the way, go ahead and connect the GND and 5V from the microcontroller to the breadboard.
Now just insert each led into the board and connect resistors to the bent (anode) part of the legs and the GND rail. Then connect a jumper wire from the longer legs and into pins 9, 12, and 13.
Step 2: Step 2: Active Buzzer
Now, this part is simple just connect a jumper wire going from the shorter leg of the active buzzer to the GND rail and another jumper wire to the longer leg to pin 7.
Step 3: Step 3: Ultrasonic Sensor and Code
The last step is to insert an ultrasonic sensor to the board and connect VCC to the power rail, Trig to pin 2, Echo to pin 3, and finally GND to the GND rail.
Credit: Math for the distance sensor