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