Start Up Guide: Arduino Stopwatch
by hIOTron IoT in Circuits > Arduino
411 Views, 0 Favorites, 0 Comments
Start Up Guide: Arduino Stopwatch
This project is about building your own stopwatch using the Arduino board and a few other components.
Hardware Components Required
Arduino Uno Board
LCD with I2C Converter
Buzzer
Rotary potentiometer (generic)
Jumper wires (generic)
Breadboard (generic)
Circuit Connection
With the help of Arduino Stopwatch, You can set the time without making any change in the code and it actually lets you know when it reaches zero.
Connections
The connection is between Arduino and 16x2 LCD screen.
LCD RS pin to digital pin 12
LCD Enable pin to digital pin 11
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 4
LCD D6 pin to digital pin 3
LCD D7 pin to digital pin 2 In addition to that wire a 10k pot to +5V and GND, with it's output to LCD screens VO pin (pin3).
A 220-ohm resistor is used to power the backlight of the display, usually on pin 15 and 16 of the LCD connector. After making connections and uploading the program into the board.
Set the time between a range of 1 and 120 minutes. After identifying the time, it waits for 5 seconds and starts counting down. When the time is up, it beeps a few times.
The Internet of Things Course Training is the way to start with such projects and to implement your Ideas on the Arduino.
Circuit Schematic
Run a Program
#include
#include
LiquidCrystal_I2C lcd(0x27,20,4); //this values will help us to choose the time
long last_change;
long last_value; long timer_value;
void setup()
{
//inti lcd
lcd.init(); //turn on backlight lcd.backlight();
pinMode(A0, INPUT);
pinMode(8, OUTPUT);
}
void loop()
{ //if the value was changed less than 5 seconds ago this loop will work while(millis() - last_change < 5000)
{
timer_value = map(analogRead(A0), 0, 1023, 1, 120);
if(timer_value != last_value)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Timer");
lcd.setCursor(0,1);
lcd.print(timer_value);
last_value = timer_value;
last_change = millis();
}
delay(10);
} //after 5 seconds this will happen lcd.clear();
lcd.print("starting..."); delay(3000);
long target = last_change + (timer_value * 60 * 1000); //and then it will start displaying how much time there is until end of counting
while(millis() < target)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Time left:");
lcd.setCursor(0, 1);
lcd.print((target - millis()) / 1000 / 60);
delay(50);
}
//and few beeps at the end
for(int a = 0; a < 10; a++)
{
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
}
while(1);
}