Beginner stopwatch

Hello! I'm a beginner in using arduino and currently trying to build a stopwatch with a button that stop/starts the timer, but got really stuck at the moment, for now I've been trying to use tinkercad before actually using the real components since I thought I'd be a better idea. I've been following this tutorial https://www.youtube.com/watch?v=kVBe3pCWCHA&t=108s.
It consists of using 1 pushbutton, 1 10000 kΩ Potentiometer, 1 Arduino Uno R3 and an 1 Arduino Uno R3
The current issue is that upon running the code the lcd does nothing even after uploading the code or pressing the button, here's the schematic I made on tinkercad:

The code I've been using:

#include <LiquidCrystal.h>

#define button 2

int timerMode = 0;
long startTime;

LiquidCrystal lcd(7,8,9,10,11,12);

void setup() {
  lcd.begin(16,2);
  lcd.clear();
  pinMode(button, INPUT_PULLUP);
  lcd.print("Press to start:");
}

void loop() {
  lcd.setCursor(0, 1);
  if (digitalRead(button) == LOW) {
    startTime = millis();
    timerMode++;
    delay(400);
  }
  if(timerMode == 1) {
    lcd.setCursor(0,1);
	lcd.print((millis() - startTime) / 1000.0);
  }
  if (timerMode > 1) {
    delay(2000);
    timerMode = 0;
    lcd.clear();
    lcd.print("Press to start");
  }
}

If anyone could help or perhaps tweak the schematic I've been making that would be a really huge help, this is the link: Circuit design Stopwatch - Tinkercad

Try one of the example sketches from the <LiquidCrystal.h> library to test if your display is connected properly and is not faulty.

Show a picture of your LCD connections and make a wiring diagram that shows pin numbers.

Your code works. Check wiring.

Files for WOKWI.COM

sketch.ino
#include <LiquidCrystal.h>

#define button 2

int timerMode = 0;
long startTime;

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  pinMode(button, INPUT_PULLUP);
  lcd.print("Press to start:");
}

void loop() {
  lcd.setCursor(0, 1);
  if (digitalRead(button) == LOW) {
    startTime = millis();
    timerMode++;
    delay(400);
  }
  if (timerMode == 1) {
    lcd.setCursor(0, 1);
    lcd.print((millis() - startTime) / 1000.0);
  }
  if (timerMode > 1) {
    delay(2000);
    timerMode = 0;
    lcd.clear();
    lcd.print("Press to start");
  }
}
diagram.json
{
  "version": 1,
  "author": "Anonymous maker",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-nano", "id": "nano", "top": -4.8, "left": -38.9, "attrs": {} },
    { "type": "wokwi-lcd1602", "id": "lcd1", "top": -207.77, "left": -89.6, "attrs": {} },
    {
      "type": "wokwi-pushbutton",
      "id": "btn1",
      "top": -51.4,
      "left": 153.6,
      "attrs": { "color": "green" }
    }
  ],
  "connections": [
    [ "lcd1:RS", "nano:7", "green", [ "v57.6", "h57.9" ] ],
    [ "lcd1:E", "nano:8", "green", [ "v9.6", "h-28.8" ] ],
    [ "lcd1:D4", "nano:9", "green", [ "v19.2", "h-96" ] ],
    [ "lcd1:D5", "nano:10", "green", [ "v28.8", "h-105.5" ] ],
    [ "lcd1:D6", "nano:11", "green", [ "v38.4", "h-124.6" ] ],
    [ "lcd1:D7", "nano:12", "green", [ "v48", "h-143.7" ] ],
    [ "nano:2", "btn1:1.l", "green", [ "v0" ] ],
    [ "nano:5V", "lcd1:A", "red", [ "v-105.6", "h-9.5" ] ],
    [ "nano:GND.1", "btn1:2.l", "black", [ "v0" ] ],
    [ "nano:GND.1", "lcd1:K", "black", [ "v-115.2", "h-19.2" ] ]
  ],
  "dependencies": {}
}

I keep checking but everything looks fine, perhaps the potentiometer could be the issue?

Remove the potentiometer and try again.

A wire was in the +zone instead of the - actually and I fixed that, now the connection to the lcd is made but we're apparently getting too much backlight, I checked a lot and I really cannot see anything else wrong, any ideas? Is it that this potentiometer in tinkercad has all its 3 terminals in the front instead of 2 in the front and 1 in the back and I didn't place the wires for it right?

Yes. You are not verifying the wiring is correct.

Check that your LCD wiring is similar to the following (Fig-1):


Figure-1:

Please post photos of your setup.

Some breadboards have split power rails. You may need to install jumpers to connect and complete the rails.

1 Like

Start by just using the lcd example from the library and twiddle the pot to get the best readability .
When that works try your stopwatch .

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.