Arduino Stopwatch Project
By utilizing Arduino Leonardo in this Arduino project, I have successfully made a custom stopwatch with led and alarm. The stopwatch contains two buttons, one to start the stopwatch, another to stop and restart the stopwatch. There are two led light, a green and a red, on the stopwatch. The green led shines when the stopwatch starts counting, and the red shines when the stopwatch stops via button press. The stopwatch is projected on a LCD screen which exhibits the time in seconds.
This designed originated from this link (Thank you for the creator for providing inspiration)
Credit: https://www.instructables.com/Arduino-Stopwatch-Us...
Supplies
Supplies:
1. Arduino Leonardo
2. Arduino Breadboard
3. Several jumper wires
4. Two buttons
5. 4 330k resistors
6. LCD display with 12C module
7. Round Micro Speaker Diameter 28mm 8Ohm 8R 2W for Arduino
8. Power (whether a battery or a laptop)
9. 2 5v LED (preferably green and red)
9. Cardboard box (optional)
(All materials can be found in local hardware stores or online shops)
Connect the LCD
Take the LCD and 4 jumper wires. Connect one end of the jumper wire to the connection point of the LCD, repeat this process four times until all the connection points of the lcd has been connected to a jumper wire. Then use the SCL and SDA end of the jumper wires connected of the LCD (listed besides the connection point on the lcd) and connect it to the Arduino Leonardo board where it also states SDL and SDA (refer to the two white wires). The other two wires connected to the LCD connection points (orange wires) should be connected to the top left of the breadboard (refer to the picture for detail).
Connecting the Buttons
Connect the two buttons to the Arduino breadboard via four jump wire (two each) linkage since the buttons need them to be able to connect to the breadboard. Connect a wire to the first button (the one on the left of the pictures) as the start button and link the other side to pin 8 of the Arduino Leonardo board. Connect another wire to the second button (the one on the right of the pictures) as the stop and reset button and link the other side of the wire to pin 9 of the Arduino Leonardo board. The final step is to connect two resistors to two buttons to prevent voltage outbursts as in the pictures (route the green and white jump wires powering the resistors to the top left of the breadboard as shown in the picture).
Connecting the Two LEDs
Take two LEDs (preferably red and green) and place them on the breadboard. Once the LEDs are on the breadboard, connect a jumper wire to the two LEDs. Connect one of the LED using a jumper wire to pin 4 and the other LED to pin 7 as shown in the pictures. Then use two resistors on each Led to prevent blowing the LEDs (route the yellow jump wires that power the resistors to the top of the breadboard as shown in the picture).
***(extension jumper wires for the LEDs on the cardboard as shown in the pictures are optional, but the connection logic is equal to the procedure written)
Connecting the Round Micro Speakers
Connect the micro speaker's wires, positive and negative (red and black) to the Arduino Leonardo. The black wire of the micro-speaker has to connect to the GND connection point, and the red wire of the micro-speaker has to connect to pin 11 (or the pin of your choice).
CODING
You can download the code for this project via the file below or preview/copy the code here: https://create.arduino.cc/editor/popul4r/66708ccb...
The code of this project consists of three main things:
1. The function of the two buttons
2. The function of the LEDs
3. The function of the speaker
One button (Button 1) in the project will function as a start button to the stopwatch (before anything is pressed, the LCD screen will instead show the message "press the button" to instruct the user). When the first button is pressed, the stopwatch will start counting up in seconds. The first button is connected to pin 8 of the Arduino board
The second button (Button 2) will act as a stop and restart function for the stopwatch. When the second button is pressed, the stopwatch will first stop, then if pressed again will restart the stopwatch. The second button is connected to pin 9 of the Arduino board
One led will be green and one will be red (or any other color). One led will be on when the stopwatch is counting, while another will be on when the stopwatch stops counting. In this project, the green led turns on when the count starts, while the red one is not. When the stopwatch stops, the red led turns on instead of the green one. The pin for the green LED is pin 4 and the red LED is pin 7.
The speaker will make a frequency wave or a buzzing sound when the stopwatch restarts. So if button 2 is pressed two times, the speaker will automatically turn on and make a sound to warn the user that the stopwatch has restarted. The sound will continue until button 1 is pressed to start the stopwatch again.
Downloads
YOU'RE DONE
The project is finished, upload the code to the computer then plug-in power to the Arduino Leonardo for the project to start operating (the cardboard box shown in the photos is optional).
Here is the video of the finished project!!!
Make sure to change the input pins in the code if you have changed them in the project!!!