hi frnds…i want to send command using keypad on serial monitor…and that send command i want to display on lcd…i m getting problem …plz help me…thnku in advance
#include <LiquidCrystal.h>
#include <Keypad.h>
// initialize the lcd library with the numbers of the interface pins
LiquidCrystal lcd(11,12,25,24,23,22);
//define the keypad
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] = {9,8,7,6};
byte colPins[cols] = {5,4,3,2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("DC MOTOR CONTROL");
lcd.setCursor(0,1);
lcd.print("****WELCOME****");
delay(5000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("GiveCount:");
lcd.setCursor(0,1);
lcd.print("MotorCount:");
Serial.begin(9600);
}
void loop(){
char keypressed = keypad.getKey();
if (keypressed != NO_KEY)
{
Serial.println(keypressed);
if (keypressed == 'A')
{
lcd.setCursor(10,0);
lcd.write(" ");
lcd.setCursor(10,0);
} else
lcd.print(keypressed);
}
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
// lcd.setCursor(0,0);
lcd.write(Serial.read());
//lcd.setCursor(0,1);
}
}
}