Simple Alarm and Distance Meter - borq79/cs.edu GitHub Wiki

Simple Alarm and Distance Meter

Borrowed From Here and Here

This project allows you to start learning how to program the Arduino microcontroller. Upon completion of this project you should have some basic understanding of how to update the Arduino's programming and wire up a simple project. The Arduino kit used in this project allows you to easily transition to other projects on this page as several of them utilize the this kit.

Parts List

Steps

  1. Program the Arduino by following the steps below
  2. Solder the three wires to the LED strip
  3. Wire up the entire project according to the schematic below

Tips for a successful project

  • Some of the parts may not match 100% to the pins on the schematic. Review the pin names (e.g. Vin, GND) to be sure you have it wired up correctly before supplying power to the Arduinio
  • Make sure the capacitor is oriented correctly. It has polarity and has to be in the right way in order to work (the gray paint should help you position the part correctly).
  • The distance sensor requires you to have approximately 71cm (28" inches) of distance between the sensor and the edge of the door. To test this out in the lab, put up a stationary object (e.g. back of the laptop) and place the sensor about 71cm away from the object. Hold the sensor still. Then run your hand between the sensor and the stationary object to simulate someone walking through the door.

Customizing your alarm

  • If you wish to change how long the alarm sounds, change this line. The time is in milliseconds (1 second * 1000).
  • Currently you CANNOT change the color of the text on the display as it is a monochromatic display and only shows text in yellow. You can change the text size, however, by editing these lines
  • Change the distance (width) of the sensor for your size door here
  • This method can be changed to only update the display and not sound an alarm but you may require assistance. The first two if statements should be commented out. Another option is to simply remove the speaker and/or lights from the board.

Schematic

Code

Arduino Source

Steps to Program

  1. Download the source code zip file here. Note As the zip file is quite large, you could also skip the download of the zip file (and the next step) and download the files individually. To do so create a directory (on the Desktop is fine) called 'alarm' and download all .cpp, .h, .c, and .ino files and then open the project by double clicking on the alarm.ino file.
  2. Extract the zip file (on the Desktop is fine) and go to the folder projects/arduino/simple_alarm_system/src/alarm/ and double click on the alarm.ino file to open the project.
  3. Download the Library that controls the Distance Sensor Here
  4. Download the Library that controls the Piezo Here
  5. Import the two libraries into the Arduino IDE
    1. Go to Sketch -> Include Library -> Add .ZIP Library...
    2. Select the zip file you downloaded in step 2
    3. Repeat this step for the library downloaded in step 3
  6. Import the Adafruit NeoPixel Library into the Arduino IDE
    1. Go to Sketch -> Include Library -> Manage Libraries...
    2. Search for 'Adafruit Neopixel'
    3. Select the 'Adafruit Neopixel' cell and then click install
  7. Compile the Source
  8. Send the Program to the Arduino. Instructions here on how to do this.
⚠️ **GitHub.com Fallback** ⚠️