Introduction: Servo Motor Arduino and Button/drawer Locker

    The purpose of this project is to keep our little siblings away from our stuff

    It works like this: you put it inside your drawer hiding the buzzer outside, and when you press the button your drawer opens and you have some seconds (you decide the time in the code of the project) to take your things before the servo motor locks again

  • For this project you will need a servo motor, breadboard, an arduino, 9 jumper cables, a button, resistor and a USB cable. The servo motor is connected with three wires, the power, the ground and the signal.

Step 1: Step 1

First you are going to get an arduino and the jumper cables, then you are going to connect one of the cables to the pin numer 2 and the bread board, then you are going to connect the yellow cable of the servo to the pin numer ~11

Step 2: Step 2

Now you need to get a button and position it on the bread bord on the same line of the cable in pin numer 2

Step 3: Step 3

Then you are going to get the servo and connect the middle cable on the positive powerale and the brown one above him.

Step 4: Step 4

Now you are going to connect a cable behind the button to the same line of the brown cable of the servo motor.

Step 5: Step 5

Then you connect two cables on the arduino pin 5v and GND on the same line of the cables of the servo.

Step 6:

And the last two steps are, connect a resistor under the button to the bread board and connect another cable beside the resistor into the same line that the cables of the servo on the bread board

Step 7: CODE

#include Servo myservo; // create servo object to control a servo const int buttonPin = 2; // the number of the pushbutton pin//int buttonState = 0; // variable for reading the pushbutton statusconst int outputPin = 9; // servo signalint pos = 90; // variable to store the servo position void setup() { // Serial.begin(9600); // for sending data to serial monitor pinMode(ledPin, OUTPUT); myservo.attach(outputPin); // attaches the servo on pin 9 to the servo object pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:} void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { myservo.write(pos); // set the servo position } }