My Lcd Display show nothing. It is connected with the arduino as follows : GNd with GND , UCC with 5V , SDA with SDA and SCL with SCL. I want my LCD display to show me a score. If the first time 300 is exceeded , a 1 should be on the display , the second time a 2 and the third time a 3 . If it is three it should show the bracketed (“ Du hast gewonnen" ). My problem: my display shows nothing at all.
Script:
int Lichtschranke = 0;
int x=1;
#include <Wire.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C Lcd(0x27,16,2);
void setup() {
Lcd.init();
Lcd.backlight();
Serial.begin(9600);
}
void loop() {
int widerstand = analogRead(Lichtschranke);
Serial.println(widerstand);
if(widerstand > 300) { Lcd.print(x);
// Hier fehlt eine Aufzählung Also wenn beim ertsen mal 300 übertreffen ist dann "1" und beim zweiten mal übertreffen "2" usw. bis drei und wenn es genau drei ist soll das untere passieren
}
if(x==3) { Lcd.print("Du hast gewonnen!");
tone(7,147);
delay(1000);
tone(7,130);
delay(1000);
tone(7,123);
delay(1000);
tone(7,110);
delay(1000);
tone(7,98);
delay(2000);
noTone(7);
}
delay(1000);
}
Few options:
-have you checked the actual I2C adress of the LCD? (0x27 in your code)
-where did you set the inital position, whre to print your text?
-what is the scope of your analogRead? Does widerstand exceed 300?
Post an annotated schematic as to how you have it wired, include all connections including power supplies, ground and power. Also include links to "Technical" information on each of the hardware parts. I assume you ran a I2C scan, what did it tell you? Did you use 4.7K pull ups on SCL and SDA, they are required for it to operate properly.