Introduction: Raspberry Pi 3 Timer With Servo Motor

The purpose of this build is to create an automated timer with set times utilizing the Servo. It uses the raspberry pi 3 as the computer and Python for the code.

Step 1: Step 1: What You Need

There is a total of 17 parts that are needed to build this circuit. The main part needed for this timer to work is a servo motor preferable the SG92R model, the purpose of this servo is to be the moving part of the timer. In python, you can set the exact angle you want the servo to go allowing it to be a great use for a timer. The other parts needed are three buttons (each of them for a different time), one LED (to indicate when time is up), a 330-ohm resistor (for the LED circuit), 13 jumper/cables (to connect everything) and 1 breadboard for putting it all together. If you would also like to make the casing you will some type of clear box some foam board and plastic disk.

Step 2: Step 2: the Circuit

The Circuitry is relatively simple but I will still explain it -

Servo: To wire the servo you will need the servo itself and three jumper cables. First, put each of the jumper cables to the three wires on the servo. After, look at the colors of the servo, brown = ground (GND), red = voltage (5V), and orange = GPIO.

Button: To wire, each of the buttons takes one jumper to connect it to a GPIO port and connect it to one peg on the button. Then, take another jumper to connect it to ground and place to the adjacent peg of the GPIO peg. Do this again two times to the other two buttons and connect them to two different GPIO pins.

LED: To wire the LED you will need two jumpers (one for ground and one for the GPIO pin), a 330-ohm resistor and the led its self. start by taking one of the jumper cables and putting it to ground then connect that wire to the resistor. After, take the led and connect the smaller peg to the resistor then take the second jumper cable and connect it to a new GPIO port (different from the servos and the buttons) and connect the other side of the jumper to the other leg of the LED.

Hint: You can use two more jumpers to extend the ground and a GPIO port to the side of the breadboard.

Step 3: Step 3: the Code

The code for the Raspberrypi timer mostly derives from the gpio zero library and is not hard to replicate-

My correction/Min and Max: After, exporting the functions from the library there is a patch the is my corrections and min and max PW. What this code does is that it set up the pulse width of the servo so that it can function at its best.

Variables: For this code, you need 5 variables one for the servo, the three different buttons, and the LED

Main Code: For this explanation, I will be talking about one block as the other two are the same. What the main code does is that it creates an increment of the servo going up the code then repeats this increment 20 times which will make it reach its full cycle. the second if in this block is for the led it senses when the cycle is finished and then turns the LED on and off.

Step 4: Step 4: Casing

To finish this off you will want some sort of a Casing to cover up the circuitry. What I did is take a clear plastic box that once had screws in it cut the side so the raspberry pi could fit in it and then added holes for the buttons and the LEDs, I also lined the box with foam so the circuit would be safe. Finally for the servo, what I did was take a plastic boxes lid and made a circle out of it to serve as a clock face.

Step 5: Better Understanding

This video provides a better understanding of the circuit.