Hellow alle zusammen,
Ich habe ein kleines Programm für mein Bruder geschrieben, dass er endlich mal eine Alarmanlage hat. Also des Programm ist für eine Lichtschranke.
Hier der Code:
#include <LiquidCrystal.h>
const int Laser = 3;
const int Piezo = 2;
const int Fotowiederstand = A1;
int normal;
int value;
int lcdState = 0;
void setup() {
// put your setup code here, to run once:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
pinMode(Laser, OUTPUT);
pinMode(Piezo, OUTPUT);
digitalWrite(Laser, HIGH);
normal = analogRead(Fotowiederstand) - 50;
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(Fotowiederstand);
if (value <= normal) {
tone(Piezo, 100);
if (lcdState = 0){
lcd.clear();
lcd.print("Alles gut keine Sorge.");
lcdState = 1;
}
}
else {
noTone(Piezo);
if (lcdState = 1) {
lcd.clear();
lcd.print("ALARM!!!");
lcdState = 0;
}
}
}
Wenn ich den Code jetzt kompeliere sagt er mir:
C:\Users\Lars\Documents\Arduino\Laserschranke\Laserschranke.ino: In function ‘void loop()’:
Laserschranke:24:3: error: ‘lcd’ was not declared in this scope
lcd.setCursor(0, 0);
^
exit status 1
‘lcd’ was not declared in this scope
Soweit ich weiß heißt das, dass das Programm nicht weiß, was “lcd” bedeutet, obwohl ich dem Programm das doch vorher mit dem ganzen initialisier-Kram gesagt habe.
Jetzt weiß ich halt nicht was ich ändern kann, um zu machen, dass das Programm funktioniert.
Kann mir bitte jemand helfen?
Schon einmal Danke im Voraus.
Viele liebe Grüße, Hellow2