I have never used an lcd on Arduino before. I used Chat GPT to help write code to use as a stopwatch with a magnetic reed switch to tell how long it has been since I have last opened the oven. When Power on the Arduino, the [display] just shows bright blue with no text. (Amazon.com: HiLetgo 2pcs DC3.3V HD44780 1602 16x2 Character LCD Display Adapter Module Blue Backlight for Arduino UNO R3 MEGA2560 Nano Due Raspberry Pi : Industrial & Scientific) I have used a multimeter to check every connection between the Arduino and the display. I don’t have a 10k potentiometer so I am using different normal resisters to control the contrast.
The display was using too much power so I have connected a 5v power supply to the 5v out and GND
VSS: GND
VDD: 5V
V0 : Resister: Ground (I have tried multiple different resistance levels)
RS: Arduino Pin 7
RW: GND
E: Arduino Pin 8
D0-D3 : Left Unconnected
D4 : Arduino Pin 9
D5: Arduino Pin 10
D6: Arduino Pin 11
D7 : Arduino Pin 12
A: 5V
K : GND
ChatGPT's code;`
#include <LiquidCrystal.h> // Include the LiquidCrystal library for LCD
#define OvenSwitch 2 // Define the pin for the oven switch
long ovenMillis = 0; // Variable to store the time when the oven switch was last pressed
long elapsedMillis = 0; // Variable to store the elapsed time since the oven switch was last pressed
// Initialize the LiquidCrystal object with the pin numbers where the LCD is connected
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
lcd.begin(16, 2); // Set up the LCD's number of columns and rows
lcd.clear(); // Clear the LCD display
pinMode(OvenSwitch, INPUT_PULLUP); // Set the oven switch pin as an input with an internal pull-up resistor
lcd.setCursor(0, 0); // Set the cursor to the first column, first row
lcd.print("Oven Last Opened"); // Print the message on the first row of the LCD
ovenMillis = millis(); // Initialize ovenMillis to the current time in milliseconds
}
void loop() {
if (digitalRead(OvenSwitch) == HIGH) { // Check if the oven switch is pressed
ovenMillis = millis(); // Reset ovenMillis to the current time in milliseconds
}
elapsedMillis = millis() - ovenMillis; // Calculate the elapsed time since the oven switch was last pressed
// Convert elapsed time into hours, minutes, and seconds
unsigned long displaySeconds = (elapsedMillis / 1000) % 60; // Calculate the seconds part
unsigned long displayMinutes = (elapsedMillis / 60000) % 60; // Calculate the minutes part
unsigned long displayHours = (elapsedMillis / 3600000); // Calculate the hours part
lcd.setCursor(0, 1); // Set the cursor to the first column, second row
lcd.print("Time: "); // Print "Time: " on the LCD
lcd.print(displayHours); // Print the hours part on the LCD
lcd.print(":"); // Print the colon separator on the LCD
lcd.print(displayMinutes); // Print the minutes part on the LCD
lcd.print(":"); // Print the colon separator on the LCD
lcd.print(displaySeconds); // Print the seconds part on the LCD
lcd.print(" "); // Print spaces to clear any extra characters on the LCD
delay(400); // Small delay to update the display every 400ms
}
`
Thank you for your help!