I am using a 20x4 LCD screen to display certain recorded values. I get it to work when it is connected to my computer, however, once I change it to be plugged into a battery or wall outlet the display just displays white boxes on the 1st and 3rd rows. I have clearly updated a code to it but it still doesn't work. The led that I have connected also doesn't blink when it is plugged into battery or wall outlet either. I was wondering why the difference in output when power source changes and any potential fixes. Thank you in advance.
LED: https://www.amazon.com/gp/product/B00KWGJWYM/ref=oh_aui_detailpage_o05_s00?ie=UTF8&psc=1
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
const int ledPin = 13;
int ledState = LOW;
unsigned long previousMillis = 0;
void setup() {
pinMode(ledPin, OUTPUT);
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.begin(16, 2);
lcd.setCursor(0,0);
Serial.begin(9600);
lcd.print("RPM = ");
lcd.setCursor(0,1);
lcd.print("Temp (F) = ");
lcd.setCursor(20,0);
lcd.print("Bearing Life = ");
}
void loop() {
unsigned int interval = analogRead(A2);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
lcd.setCursor(6,0);
lcd.print(interval);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}