Hello, i'm making a arduino program for my year project. It's my first time using an lcd display and I have a problem. When I make a simple program with just the lcd in it, everything works just fine, but when I add the part that 'makes' the project, weird characters appear on my lcd.
My simple code:
#code
#include <LiquidCrystal.h>
LiquidCrystal lcd( 1, 2, 4, 5, 6, 7); //RSP (RS), Enable (E), Register D4-D7
void setup() {
lcd.begin(16, 2); //lcd 16*2 vakjes
}
void loop() {
//schrijven van: Injectie: 1000ms op 1ste rij lcd scherm
lcd.print("Injectie: ");
lcd.print(1000);
lcd.print("ms");
delay(100);
//schrijven van: Sluit: 2000ms op 2de rij lcd scherm
lcd.setCursor(0, 1);
lcd.print("Sluit:");
lcd.print(2000);
lcd.print("ms");
delay(2000);
//leegmaken lcd scherm
lcd.clear();
delay(500);
}
My program with everything in it:
#code
/*Change the injectiontiming for ethanol by setting 2 timers with 4 buttons*/
#include <LiquidCrystal.h>
#include <Bounce2.h>
#define UP1 10
#define DOWN1 11
#define UP2 12
#define DOWN2 13
Bounce debouncer1 = Bounce(); //UP1
Bounce debouncer2 = Bounce(); //DOWN1
Bounce debouncer3 = Bounce(); //UP2
Bounce debouncer4 = Bounce(); //DOWN2
int pinRelais = 8;
int delayInjectie = 0;
int delaySluit = 0;
LiquidCrystal lcd( 1, 2, 4, 5, 6, 7); //RSP (RS), Enable (E), Register D4-D7
void setup() {
// eerste drukknop UP1
pinMode(UP1, INPUT_PULLUP);
debouncer1.attach(UP1);
debouncer1.interval(5);
// tweede drukknop DOWN1
pinMode(DOWN1, INPUT_PULLUP);
debouncer2.attach(DOWN1);
debouncer2.interval(5);
// derde drukknop UP2
pinMode(UP2, INPUT_PULLUP);
debouncer3.attach(UP2);
debouncer3.interval(5);
// vierde drukknop DOWN2
pinMode(DOWN2, INPUT_PULLUP);
debouncer4.attach(DOWN2);
debouncer4.interval(5);
pinMode(pinRelais, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
}
void loop() {
debouncer1.update();
debouncer2.update();
debouncer3.update();
debouncer4.update();
int value1 = debouncer1.read();
int value2 = debouncer2.read();
int value3 = debouncer3.read();
int value4 = LOW;
//debouncer4.read();
if (value1 == HIGH) {
delayInjectie += 250;
}else if (value2 == HIGH) {
delayInjectie -= 250;
}
if (value3 == HIGH){
delaySluit += 250;
} else if (value4 == HIGH){
delaySluit -= 250;
}
Serial.print("delayInjectie =");
Serial.println(delayInjectie);
Serial.print("delaySluit =");
Serial.println(delaySluit);
Serial.print("value1 ");
Serial.println(value1);
Serial.print("value2 ");
Serial.println(value2);
Serial.print("value3 ");
Serial.println(value3);
Serial.print("value4 ");
Serial.println(value4);
lcd.clear();
lcd.print("Injectie: ");
lcd.print(delayInjectie);
lcd.print("ms");
lcd.setCursor(0, 1);
lcd.print("Sluit: ");
lcd.print(delaySluit);
lcd.print("ms");
digitalWrite(pinRelais, HIGH);
delay(delayInjectie);
digitalWrite(pinRelais, LOW);
delay(delaySluit);
}
Here is an image of the LCD display with wrong characters: 20200412_225046.jpg - Google Drive
I've been searching for several hours but didn't find it...