MATHEW
MATHEW
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address (0x27 for a 16x2 display)
void setup() {
lcd.print("Hello, World!");
void loop() {
EXPERIMENT 2 CODE
#include <Wire.h> // Include the Wire library for I2C communication
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
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”);
EXPERIMENT 3 CODE
#include <Wire.h> // Include the Wire library for I2C communication
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(“:”);
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”);
}
EEPROM.write(address, lowByte);
EEPROM.write(address + 1, highByte);