A Maker by the name of James Bruce has designed a simple alarm system powered by an Atmel-based Arduino board, an ultrasonic “ping” sensor (HC-SR04 or PIR), a piezo buzzer and LED strip light. On the software side, Bruce uses a library known as NewPing.
“Download and place in your Arduino’s Library folder and restart the IDE before continuing. Test using this code; open up the serial monitor and make sure the speed is set to 115200 baud,” he explained on a recent MakeUseOf blog post.
“With any luck, you should see some distance measurements being send back to you at a pretty high speed. You may find a variance of 1 or 2 centimeters, but this is fine. Try running your hand in front of the sensor, moving it up and down to observe the changing readings.”
According to Bruce, the code should be fairly simple to understand.
“There are a few declaration of relevant pins at the start, including a maximum distance – this may vary according to the exact sensor you have, but as long as you’re able to get less than 1 meter readings accurately, you should be fine,” he added.
Interested in learning more about the simple alarm system described below? You can find detailed instructions on MakeUseOf here.