Thursday, February 11, 2016

Arduino Servo Motor Lock

      After completing one of the projects in the Arduino Starter Kit, I decided to change it up and make it a little bit more secure. Instead of simply doing 3 knocks on a piezo, I decided to make it password protected. I attached 5 pushbuttons to the Arduino digital pins and used digitalRead to read their current state. At first, the password didn't work and I had to look in the internet for answers. I found an easy way to do it and got acquainted with static int in C++. If the person's password is wrong, a piezo will play something similar to a police siren and the RGB Led will alternate blue and red colors. At first I used, 2 normal leds, but later decided to use something more interesting. The RGB led can light up as green, blue, or red and any combination of those colors. If the user gets the password right, the servo in the box will turn and enable the person to open the box. After 5 seconds, it will automatically close. I was previously thinking about using an LCD screen to display text depending if you entered the right combination or not. Later, I found out that it took up too much space on the breadboard and too many of the digital pins. I needed 5 digital pins for the buttons, one for the piezo, 1 for the servo motor, and 3 for my RGB Led. I ran into some difficulties when trying to use PWM on some of my digital pins. I found out that if you use a servo motor and/or piezo, certain digital pins will not be able to use Pulse Width Modulation. Because of that, my jumper cables were a mess and I had to reposition some components on the breadboard. I cut 3 holes in a cardboard box: one for the wire, one through the lid, and one through the box. The plastic part of the servo motor sticks out through two of the holes, potentially blocking the user from accessing the contents of the box. Below you can see some photos and a video of my creation in actions. I am thinking about making a youtube video on how to build this.
Servo motor inside the box

My Breadboard