Arduino_LCD_Automatic_StopWatch
Arduino_LCD_Automatic_StopWatch
Storage
Introduction
In this lab, you will learn how to interface an I2C (I²C or Inter-Integrated Circuit) LCD display
with an Arduino microcontroller. LCD displays are widely used for visualizing data and messages
in various electronic projects. Interfacing an I2C LCD with Arduino simplifies the connection and
reduces the number of pins required, making it an efficient choice for your projects.
Objectives
Understand the basics of LCD displays and their importance in microcontroller projects.
Write and upload Arduino code to display text and custom characters on the LCD screen.
Materials
I2C LCD module (e.g., 16x2 or 20x4 LCD with I2C backpack).
Jumper wires.
Breadboard (optional).
Procedure
Connect the VCC (power) and GND (ground) pins on the LCD module to the 5V
and GND pins on the Arduino, respectively.
Connect the SDA (data) and SCL (clock) pins on the LCD module to the
corresponding pins on the Arduino. On most Arduino boards, SDA is A4, and SCL
is A5.
To easily control the I2C LCD, you will need to install the “LiquidCrystal I2C” library.
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address (0x27 for a 16x2 display)
void setup() {
lcd.print("Hello, World!");
void loop() {
}
Make sure to modify the LiquidCrystal_I2C constructor with the correct address
(0x27 is common, but it may vary depending on your module).
Select the correct Arduino board and port in the "Tools" menu.
Click the "Upload" button (arrow icon) to upload the code to the Arduino.
Step 4: Testing
1. After uploading the code, you should see the text “Hello, World!” displayed on your
LCD.
2. Experiment with the LCD functions and display your own messages and data.
Conclusion
In this lab, you successfully interfaced an I2C LCD display with an Arduino and displayed text
on the screen. You also learned how to install libraries and write Arduino code for controlling the
LCD. LCD displays are versatile and can be used to enhance various Arduino projects by
visualizing information effectively.
Introduction
In this lab, you will learn how to design and build an automatic stopwatch using an Arduino
microcontroller and an I2C (I²C or Inter-Integrated Circuit) LCD display. A stopwatch is a valuable
tool in various applications, from sports timing to industrial processes. In this project, you will
create a digital stopwatch that starts, stops, and resets automatically.
Learning Objectives
Write Arduino code to implement a digital stopwatch with start, stop, and reset functions.
Materials
Arduino Uno or similar board.
I2C LCD module (e.g., 16x2 or 20x4 LCD with I2C backpack).
Jumper wires.
Breadboard (optional).
Procedure
Connect the VCC (power) and GND (ground) pins on the LCD module to the 5V
and GND pins on the Arduino, respectively.
Connect the SDA (data) and SCL (clock) pins on the LCD module to the
corresponding pins on the Arduino. On most Arduino boards, SDA is A4, and SCL
is A5.
Connect one terminal of each push-button to a digital pin on the Arduino (e.g., Pin
2 for Start/Stop and Pin 3 for Reset).
Connect the other terminal of each push-button to the ground (GND) through a
10kΩ resistor.
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address (0x27 for a 16x2 display)
void setup() {
lcd.print(“Press Start”);
void loop() {
if (digitalRead(startStopButtonPin) == LOW) {
if (!timing) {
timing = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Timing...");
} else {
timing = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press Start");
delay(100); // Debounce
if (digitalRead(resetButtonPin) == LOW) {
timing = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press Start");
delay(100); // Debounce
lcd.setCursor(0, 1);
lcd.print(“Time: “);
lcd.print(“s”);
}
1. Upload the code to the Arduino:
Select the correct Arduino board and port in the "Tools" menu.
Click the "Upload" button (arrow icon) to upload the code to the Arduino.
Step 4: Testing
1. After uploading the code, press the Start/Stop button to start and stop the stopwatch.
4. Experiment with the stopwatch and explore how it behaves when you start, stop, and
reset it.
Conclusion
In this lab, you successfully designed an automatic stopwatch using an Arduino and an I2C LCD
display. You learned how to interface push-button switches, control timing, and display
information on the LCD. Digital stopwatches are useful in various applications, including timing
experiments, races, and other time-sensitive tasks.
Experiment 3: Designing an Automatic Stopwatch with Lap Timing and Data Storage
Introduction
In this lab, you will learn how to design and build an automatic stopwatch using an Arduino
microcontroller and an I2C (I²C or Inter-Integrated Circuit) LCD display. This stopwatch will have
additional features such as lap timing and the ability to store recorded lap times even after the
Arduino is reset or powered off. Lap timing is useful for tracking multiple time intervals, and data
storage ensures that recorded times are not lost.
Learning Objectives
Understand the principles of digital timing, lap timing, and data storage.
Write Arduino code to implement a digital stopwatch with start, stop, reset, lap timing, and
data storage functions.
Materials
I2C LCD module (e.g., 16x2 or 20x4 LCD with I2C backpack).
Jumper wires.
Breadboard (optional).
Procedure
Connect the VCC (power) and GND (ground) pins on the LCD module to the 5V
and GND pins on the Arduino, respectively.
Connect the SDA (data) and SCL (clock) pins on the LCD module to the
corresponding pins on the Arduino. On most Arduino boards, SDA is A4, and SCL
is A5.
Connect one terminal of each push-button to a digital pin on the Arduino (e.g., Pin
2 for Start/Stop, Pin 3 for Reset, and Pin 4 for Lap).
Connect the other terminal of each push-button to the ground (GND) through a
10kΩ resistor.
If you haven’t installed the Arduino IDE, you can download it from the official Arduino website
(https://www.arduino.cc/en/software).
If you haven’t already installed these libraries (used in the previous lab (experiment)), follow
the same steps mentioned in the previous lab manual to install the “LiquidCrystal I2C” and
“EEPROM” libraries.
Step 3: Writing the Arduino Code
2. Write the code for the automatic stopwatch with lap timing and data storage:
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address (0x27 for a 16x2 display)
unsigned long lapTimes[10]; // Array to store lap times (adjust the size as needed)
void setup() {
lcd.print(“Press Start”);
for (int i = 0; i < 10; i++) { // Adjust the loop based on the number of laps you want to store
lapTimes[i] = EEPROMReadInt(eepromAddress);
eepromAddress += sizeof(int);
void loop() {
if (digitalRead(startStopButtonPin) == LOW) {
if (!timing) {
timing = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Timing...”);
} else {
timing = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press Start");
delay(100); // Debounce
EEPROMWriteInt(eepromAddress, lapTimes[lapCount]);
eepromAddress += sizeof(int);
lapCount++;
lcd.print(“Lap”);
lcd.print(lapCount);
lcd.print(“:”);
lcd.print(“s”);
delay(100); // Debounce
}
if (digitalRead(resetButtonPin) == LOW) {
lapCount = 0;
EEPROM.write(i, 0);
eepromAddress = 0;
// Reset timing
elapsedTime = 0;
timing = false;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press Start");
delay(100); // Debounce
lcd.setCursor(0, 1);
lcd.print(“Time: ”);
lcd.print(“s”);
}
// Custom function to read an integer from EEPROM
EEPROM.write(address, lowByte);
EEPROM.write(address + 1, highByte);
Select the correct Arduino board and port in the "Tools" menu.
Click the "Upload" button (arrow icon) to upload the code to the Arduino.
Step 4: Testing
1. After uploading the code, press the Start/Stop button to start and stop the stopwatch.
2. Press the Lap button to record lap times. The lap times should be displayed on the
LCD.
3. Press the Reset button to reset the stopwatch to zero and clear the recorded lap times.
4. Observe that the recorded lap times are stored in EEPROM and are retained even
after resetting the Arduino.
5. Experiment with the stopwatch and explore how it behaves when you start, stop,
reset, and record lap times.
Conclusion
In this lab, you successfully designed an automatic stopwatch with lap timing and data storage
using an Arduino and an I2C LCD display. This enhanced stopwatch is useful for tracking multiple
time intervals and ensures that recorded times are not lost even after power cycles. These features
make it versatile for various timing applications, including sports, experiments, and data
collection.