Hello, I just bought a LCD off of maker shed for an Arduino project I am working on, and when I upload the sketch(which uses the LCD) It will display the "initializing...", which is in void setup, but then It is supposed to say, "please swipe your card" int void loop. But what happens is, when the LCD is supposed to say " please swipe card" it says, "please sw" very dark so and flickering so that I can barely see it. All of the other LCD functions are working properly though Now I just uploaded the sketch again, and it says "please swipe your card" like it should, but it is still much darker text so it is harder to read.
Here is my code if anyone will help me.
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins
#define TAG_LEN 12
char tag[12] = {'0', '1', '0', '0', '4', 'D', 'D', '1', 'D', '3'}; //tag 1
char tag2[12] = {'3', '6', '0', '0', '7', '8', '9', 'B', 'B', '5'}; //tag 2
char code[12];
int bytesread = 0;
//Connections to be made:
int ledPin = 13; // Connect LED to pin 13
int rfidPin = 2; // RFID enable pin connected to digital pin 2
//Connect SOUT Pin to pin 0, does not need to be defined because 0 is the default RX pin
int val=0;
void setup() {
lcd.begin(16, 2); // set up the LCD's number of rows and columns
lcd.print("Initializing...");
delay (1000);
lcd.clear(); //Clears LCD
Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps
pinMode(rfidPin,OUTPUT); // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
pinMode(ledPin,OUTPUT); // Set ledPin to output
digitalWrite(rfidPin, LOW); // Activate the RFID reader
}
void loop() {
digitalWrite(ledPin,LOW); //LED off
digitalWrite(rfidPin, LOW); // Activate the RFID reader
lcd.setCursor(0, 0);
lcd.print(" Please Swipe");
lcd.setCursor(0, 1);
lcd.print(" Your Card");
if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 10) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
digitalWrite(rfidPin, HIGH); //Turns off RFID reader, THIS IS IMPORTANT so it doesn't double read the card
}
}
if(bytesread >= 10) { // if 10 digit read is complete
if(strcmp(code, tag) == 0) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Access Granted");
lcd.setCursor(0, 1);
lcd.println(code);
delay (1500);
lcd.setCursor(0, 1);
lcd.print("Jonnyblanch ");
digitalWrite(ledPin,HIGH);
Serial.print("Tag matches: ");
Serial.println(code);
//digitalWrite(ledPin,HIGH);
digitalWrite(rfidPin, HIGH);
delay(2000); // wait for a second or two
return; //Go to the top, skip the bottom
}
if(strcmp(code, tag2) == 0) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Access Granted");
lcd.setCursor(0, 1);
lcd.println(code);
delay (1500);
lcd.setCursor(0, 1);
lcd.print("Hector Lopez");
digitalWrite(ledPin,HIGH);
Serial.print("Tag matches: ");
Serial.println(code);
digitalWrite(ledPin,HIGH);
digitalWrite(rfidPin, HIGH);
delay(2000); // wait for a second
return;
}
else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Access Denied");
lcd.setCursor(0, 1);
lcd.println(code);
Serial.print(code);
Serial.println(" does not match");
digitalWrite(rfidPin, HIGH);
}
}
bytesread = 0;
delay(2000); // wait for a second
digitalWrite(ledPin,LOW);
}
}
}