diy: alarms part no. 2203944 - jameco electronics · diy: alarms part no. 2203944 this is a good...

4
DIY: Alarms PART NO. 2203944 This is a good educational kit, but can also be used in a practical application. There are many types of sensors used in alarm systems. This kit will demonstrate three different kinds. One is the infrared "break-beam" sensor using a laser diode module (or laser pointer pen) and a photocell. Another type is the magnetic proximity sensor usually found protecting doors or windows. A magnet is embedded in the top part of the door while the magnetic sensor is embedded in the door jam. When the door opens, the magnets are pulled apart and the alarm is tripped. This is a good sensor because it is nearly impossible to fool or disable the sensor. Also known as a Hall Effect sensor. The third sensor is a force sensitive resistor (touch sensor). It can be used to detect something stepping on it, or it can be triggered when a weight is removed. All three sensors will be integrated with an Arduino microcontroller. For practical purposes, this project will be built around a breadboard, but this can certainly be integrated into a real life project. Time Required: 1 Hour depending on experience Experience Level: Beginner Required tools and parts: Mini-grabber test leads (optional, Jameco P/N: 135299) Bill of Materials: Qty Jameco SKU Component Name 1 153605 Laser pointer pen 1 202420 CdS photocell 10 29831 1μF/50V capacitor 10 691104 10k Resistor 10 690865 1k Resistor 1 2151486 Arduino Uno 1 2128260 Force Sensing Resistor 1 2118539 2x16 LCD Display w/ RGB backlight 10 178511 PN2222 Transistor 1 20723 Solderable Breadboard 10 690646 120 ohm Resistor 1 2127718 Wire Jumper Kit 1 588131 Magnet Switch 1 222010 USB Cable (A to B) Step 1 - Review Parts and Diagram Check the parts you received with the bill of materials and make sure you aren't missing anything. Everything can be installed on the breadboard with the exception of the display. The LCD data pins have 2mm spacing and isn't exactly breadboard friendly, but if you're careful and set it up so the four back light pins hang over the side of the breadboard, you can make the data pins fit into the breadboard. Optionally, if you have a set of mini-grabbers such as Jameco P/N: 135299, you can use one for each pin, including the back light.

Upload: others

Post on 14-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DIY: Alarms PART NO. 2203944 - Jameco Electronics · DIY: Alarms PART NO. 2203944 This is a good educational kit, but can also be used in a practical application. There are many types

DIY: Alarms PART NO. 2203944

This is a good educational kit, but can also be used in a practical application.

There are many types of sensors used in alarm systems. This kit will demonstrate three different kinds. One is the infrared "break-beam" sensor using a laser diode module (or laser pointer pen) and a photocell.

Another type is the magnetic proximity sensor usually found protecting doors or windows. A magnet is embedded in the top part ofthe door while the magnetic sensor is embedded in the door jam. When the door opens, the magnets are pulled apart and the alarmis tripped. This is a good sensor because it is nearly impossible to fool or disable the sensor. Also known as a Hall Effect sensor.

The third sensor is a force sensitive resistor (touch sensor). It can be used to detect something stepping on it, or it can be triggered when a weight is removed. All three sensors will be integrated with an Arduino microcontroller. For practical purposes, this project will be built around a breadboard, but this can certainly be integrated into a real life project.

Time Required: 1 Hour depending on experience

Experience Level: Beginner

Required tools and parts:

Mini-grabber test leads (optional, Jameco P/N: 135299)

Bill of Materials:

Qty Jameco SKU Component Name

1 153605 Laser pointer pen1 202420 CdS photocell

10 29831 1µF/50V capacitor

10 691104 10k Resistor

10 690865 1k Resistor

1 2151486 Arduino Uno

1 2128260 Force Sensing Resistor

1 2118539 2x16 LCD Display w/ RGB backlight

10 178511 PN2222 Transistor

1 20723 Solderable Breadboard

10 690646 120 ohm Resistor

1 2127718 Wire Jumper Kit

1 588131 Magnet Switch

1 222010 USB Cable (A to B)

Step 1 - Review Parts and Diagram

Check the parts you received with the bill of materials and make sure you aren't missing anything. Everything can be installed on thebreadboard with the exception of the display. The LCD data pins have 2mm spacing and isn't exactly breadboard friendly, but ifyou're careful and set it up so the four back light pins hang over the side of the breadboard, you can make the data pins fit into thebreadboard. Optionally, if you have a set of mini-grabbers such as Jameco P/N: 135299, you can use one for each pin, including theback light.

Page 2: DIY: Alarms PART NO. 2203944 - Jameco Electronics · DIY: Alarms PART NO. 2203944 This is a good educational kit, but can also be used in a practical application. There are many types

The diagram shows how everything connects on the breadboard and to the Arduino, but there are a couple differences to be awareof. The LCD back light pins are shown as a separate RGB LED. There are only eight data pins for the LCD but the display used inthe image has a 16 position header. The first eight on the LCD correspond to the eight data pins and should be connected left to rightas they appear. You may also refer to the product datasheets for more detail.

You will need an Arduino library for the display. On the product page for this kit (p/n: 2203872) you will find a .zip archive that contains the sample code for testing each sensor, the final code, and the library for the display.

Step 2 - Magnetic Proximity Sensor

The magnetic proximity sensor is a two piece switch where each piece is a particular pole of a magnet. (The sensor may vary fromthe one pictured, but their function is the same.) The contacts can be either normally open and closed in the presence of a magneticfield, or normally closed and open when a magnetic field is present. The sample code for the magnetic sensor will allow you to usethe serial monitor in the Arduino IDE to view the state of the sensor when the magnetic field is applied and removed. The Arduino willdisplay a high or low and will be the deciding logic used in the alarm program later.

Connect each wire of the sensor to an isolated row on the breadboard. Use a small jumper wire to connect one row to the power railthat runs down the length of the breadboard. Using a longer jumper wire, connect the other row to digital pin 3 of your Arduino. Install a 120 ohm resistor (brown-red-brown) between the row that connects to digital I/O 3 and the ground rail that runs down thelength of the breadboard. (In the image from step 1, only the wired side of the magnet sensor is shown and looks like a reed switch.)

Page 3: DIY: Alarms PART NO. 2203944 - Jameco Electronics · DIY: Alarms PART NO. 2203944 This is a good educational kit, but can also be used in a practical application. There are many types

beam and give you some values to incorporate in the final code or in your own application. The Serial Monitor will display the valuefrom the photocell. The number should remain fairly constant while the laser is shining on it. See how the value changes when youblock the beam. The final code will check if the value is greater than or less than the value you set. I'd recommend adding a littlebuffer to the value to reduce the sensitivity.

The laser module is not shown in the diagram from step 1, but it is simple to install. There are only two wires and they are color coded for power and ground. Insert the red wire into the power rail and the black wire into the ground rail of the breadboard. If your kit has a laser pointer pen, just install the battery. You can use a tight rubber band or clamp-type paper clip to hold the button ON.

Find a couple empty rows on the breadboard and install each lead of the photocell into its own row. Connect a small jumper wire fromone lead to the power rail. Connect a longer jumper wire from the remaining lead to the digital I/O pin 8 of your Arduino. Install a 10kohm resistor (brown-black-orange) between the row that connects to the Arduino and the ground rail. You will need to position thephotocell in such a way that the laser beam is constantly shining on the photocell.

Step 3 - Laser Break Beam

A laser break-beam sensor is something you've probably encountered at a convenience store or seen in a movie protecting a bank vault from multiple angles. The laser diode module produces the laser beam and the CdS photocell will measure the brightness of the laser. Because the photocell can be influenced by ambient light, a small piece of paper rolled into a tube can serve to allow only light from the laser to enter the sensor. The downloadable LaserSample code in the zip archive will test the function of the break

Step 4 - Force Sensing Resistor

Touch sensing is accomplished with a force sensitive resistor (FSR). These polymer thick film devices exhibit a decrease inresistance when an increase in force is applied to the surface. Because the sensor reacts to forces applied, it can be placed under apanel to detect a pressure change. Another way it could be used is to monitor the presence of an object. If you know the valuemeasured when a known object is resting on the sensor, if the object is moved or removed, the alarm can react to the change in forceapplied. The sample code provided will display the reading to the serial monitor so you can decide how you want the sensor to reactin the alarm application. With no force applied to the sensor, the reading in the serial monitor should be close to zero. You willobserve how squeezing the sensor affects the value.

Install the FSR directly into two empty rows of the breadboard. Connect a small jumper wire from one lead of the FSR to the powerrail. Connect a longer jumper wire from the remaining lead to the analog I/O pin A0. Install a 10k ohm resistor (brown-black-orange)between the lead that connects to the analog pin and ground.

The schematic diagram from step 1 is representative of the included 2x20 display. There are eight pins at the bottom of the display fordata connection and four pins at the side for the RGB LED backlight. When looking down at the front face of the display, the pinassignment from left to right is pin 8 to pin 1. A green backlight will indicate a safe condition while a red backlight will indicate a faulthas been detected at one of the sensors. Be sure to use the 3.3V supply for the display at pin 5. The 2mm pin spacing on the displayis not very breadboard friendly, but you can use mini clip test leads or solder some solid jumper wire to the pins to complete theconnections if you can't make it fit on the breadboard.

Step 5 - RGB Backlit LCD

Page 4: DIY: Alarms PART NO. 2203944 - Jameco Electronics · DIY: Alarms PART NO. 2203944 This is a good educational kit, but can also be used in a practical application. There are many types

You can use the same 3.3V supply to power the common anode of the backlight. Green and blue operate at 3.3V, but red will need a120 ohm current limiting resistor (brown-red-brown) because the forward voltage requirement for red is 2.2V. The two PN2222transistors will switch the red and green backlights on or off independently. The backlight is shown as a single RGB LED on theschematic layout. For it to function properly, you will also need the library for the display. You can find it in the additional files archiveor in a link on the product page for the display.

Each transistor lead should have its own row on the breadboard. With the flat side up, pin 1 is on the left. Connect small jumpersfrom each pin 1 to the ground rail. Pin 2 is the signal wire, so connect a jumper wire from pin 2 of one transistor to digital I/O pin 9. Connect another wire from pin 2 of the other transistor to digital I/O pin 4. The last pin of the transistor will connect to the specificcolor of the back light. Connect one wire from transistor pin 3 to "G" for green and connect another wire from the other transistor pin 3to the "R" for red. The diagram from step 1 shows color coded signal wires so you know what pin controls what color.

Step 6 - Final Code Sequence

Load the final code called sensorSample. This bit of code will read all three sensors continuously and as long as all the sensors are unobstructed or in the default position, the display should light green and give the "All Clear" message. Test each sensor for the proper reaction and message. When you see everything working on the breadboard, you can imagine the practical applications of safeguarding objects and entrances of your own home.

The project can be expanded to use many more sensors or trigger an audible alarm or send a tweet in a specific situation. If you need more pins for sensors or outputs, you can upgrade to an Arduino Mega or similar.

Step 6 - Power and Ground

Connect a jumper wire from the Vin pin of your Arduino to the power rail on the breadboard. You may also need to connect anotherjumper wire from one power rail to the other on the opposite side. We are using the Vin pin because the USB port will supply +5V. Ifyou are going to use a 9V battery or AC wall adapter to power the Arduino, you should use the 5V pin of the Arduino instead.

Connect a jumper wire from the ground pin of your Arduino to the ground rail on the breadboard. Use another jumper wire to connectboth ground rails of the breadboard together.