Pomodoro Timer
This week assignment's idea is building and programing a smart circuit using an Arduino UNO which read signals from multiple input components to control multiple action components using Arduino C (Text Code).
As my project main idea is timer so i decided to make it by the pomodoro technique.
I used Wokwi to design the circuit , the resistor calculator to calculate the ohm of resistor and Arduino IDE to write and download the code on the Arduino UNO.
Materials : I used a 9 volt adapter , Arduino UNO , Ultrasonic sensor , Red led , Green led , White led , 3 resistors 220 ohm , buzzer, large Breadboard , Jumper wires , 2 crocodile wires , cardboard .
Arduino IDE
Wokwi
Resistor calculator
Wokwi circuit
My circuit in Real
I start to design the circuit using Wokwi.
1- I connect the LCD vcc to Arduino 5v pin , the GND to GND pin , SDA to A5 pin and SCL to A4 pin.
2- I connect Ultrasonic sensor Vcc to 5v pin and the echo to 4 pin and trig to pin 3.
3- I connect the buzzer negative terminal to GND and positive terminal to pin 11.
4- I connect the red led negative terminal to GND and the positive terminal with pin 8.
5- I connect the white led negative terminal to GND and the positive terminal with pin 1.
6- I connect the Green led negative terminal to GND and the positive terminal with pin 7.
7- I connect the switch terminal 1 with 5v pin and terminal 2 with pin 2 and terminal 3 with GND pin. (IN Real the switch i used have two terminals i connect one of them into GND pin and the other to the pin 2).
First : i upload the library of liquid crystal i2c for the LCD screen.
second : i define variables that i needed for the code and also defined all the pins to the name of my components to make it easier for me.
In Void setup : i define the pins input and output and i make a simple message when the users open the device.
In void loop ( first) : I begin with ultrasonic sensor and use if condition to make the distance i want for the white led to light and if the distance exceed 30 the white led will be turned off.
In void loop (second) : i also use if condition to make the switch when i pushed it , it will stop the time.
then i write Min and sec in the first line.
at the end i put if condition to count the time.
In void loop (third) : I use if condition to count till 25 and if this condition become true then he will make breaktime variable increase and make mins=0 and green led and a message says breaktime and the buzzer will be produced.
In void loop (fourth) : I use if condition that if the break time =1 he will count again by the same way he did.
In void loop (Finally) : I use if condition to count till 5 and if this condition become true then he will make breaktime variable decrease and make mins=0 and red led and a message says studytime and the buzzer will be produced.
I used the same components then i placed them into the cardboard and upload my code.
First it display a welcome message for 3 sec.
Second it count the 25 min of the studying mode and display a message with sound and light that told us the time is ended and it's breaktime.
Finally it count the 5 min of the breaking mode and display a message with sound and light that told us the time is ended and it's studytime again.
My pomodoro Timer . I test it with 2 min studying and 1 min breaking and then i change the time in the code.
Mohamed Tarek helped me in making the switch and sensor be able to read and make its function all the loop because in the first try i found that the code didn't read the switch and ultrasonic sensor except the first time i connect the Arduino with the power.
I got stuck when i finished my circuit and code and i saw that the inputs didn't make what i want , i do a lot research about this mistake and try to change the code but when i didn't figure out what is the problem , I asked my group and they helped me to know how i fix this.
This week assignment is part of my final project and i learn a lot of things about how the Arduino count the time.
we made a smart home circuit in the end of week session and it's very interesting to me.
We learn about how to debug our code and this make me learn how to find mistakes in my code if it's so small.