problems with 16X2 LCD:
Hardware used:
arduino uno, two 5v 10A relay,16x2 lcd display without i2c, 4x4 keypad, two Proximity IR sensors(yellow color), 5v ac-dc adapter,
kit components:
We have used a box in which there is dot matrix board on which arduino uno and relays were installed using screws and glue sticks with all the wires like gnd and vcc are soldered backside..
outside the box we have lcd
components away from kit without physical contact sensors , keypad
MAJOR PROBLEM FACED:
Actually when I turn on the power for arduino , the LCD works fine showing the favourable strings and the relays turn ON and bulb glows... After few minutes , there is a small strange / garbage character appears in the LCD along with string ..Then after strange/garbage characters proliferate and are piling up in the rows and my favourable required strings are replaced by those piled up strange characters..what to do....what is the problem and what is the solution.
I have not used i2c for lcd will that be a problem??
CODING:
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Wire.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {13, 12, 11, 10};
byte colPins[COLS] = {9, 8, 7, 6};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
int keypadValue = 0;
String keypadString = "";
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
int count = 0;
int display_value = 0;
int first = 0;
int second = 0;
int entering = 0;
int exiting = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PEOPLE INSIDE : ");
Serial.begin(9600);
}
void loop()
{
char key = keypad.getKey();
if(key != NO_KEY){
if(key == 'D'){
keypadValue = keypadString.toInt();
count = keypadValue;
keypadString = "";
}
else keypadString += key;
}
first = !digitalRead(3);
second = !digitalRead(2);
if(!second && !first && (entering == 3 || exiting == 3))
{
entering = 0;
exiting = 0;
}
if(first && entering != 3 && exiting != 3)
{
if(exiting == 0 )
{
entering = 1;
}
else
{
exiting = 2;
}
}
if(second && entering != 3 && exiting != 3)
{
if(entering == 0)
{
if(exiting == 0) exiting = 1;
}
else
{
entering = 2;
}
}
if(entering == 2)
{
count++;
entering = 3;
}
if(exiting == 2)
{
count--;
exiting = 3;
}
display_value = count != display_value ? count : display_value;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(display_value);
Serial.print("People inside : ");
Serial.print(count);
Serial.print(" Lights : ");
Serial.print(count ? "ON" : "OFF");
Serial.print(" Entering : ");
Serial.print(entering);
Serial.print(" Exiting : ");
Serial.println(exiting);
digitalWrite(4, count > 0 ? LOW: HIGH);
digitalWrite(5, count > 0 ? LOW: HIGH);
}