Hello!
now im doing some project using lcd and arduino mega.
i want to make sequence, when i press the push button it will display on the lcd.
the problem is the signal from push button 4 and 5 keep receiving signal without pressing them.So the lcd keep displaying the output that should be display only when push button is press.
here is my program and it will great that u guys help me out. i really appreciate that.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
pinMode(34,OUTPUT); // LED 1
pinMode(35,OUTPUT); // LED 2
pinMode(27,OUTPUT); // LED 3
pinMode(40,INPUT); // Push button 1
pinMode(41,INPUT); // Push button 2
pinMode(42,INPUT); // Push button 3
pinMode(22,INPUT); // Push button 4
pinMode(23,INPUT); // Push button 5
lcd.begin(16, 2);
lcd.print("SELAMAT DATANG");
}
void loop(){
if(digitalRead(22)==HIGH); // when push button 4 pressed
{
lcd.clear();
delay(500);
lcd.setCursor(0,0);
lcd.print("RM 1.00");
lcd.setCursor(0,1);
lcd.print("DITERIMA");
digitalWrite(34,HIGH); // LED 1
delay(1500);
digitalWrite(34,LOW); // LED 1
delay(3000);
lcd.clear();
lcd.print("TERIMA KASIH");
}
{
if(digitalRead(23)==LOW); // when push button 5 pressed
{
lcd.clear();
delay(500);
lcd.setCursor(0,0);
lcd.print("RM 5.00");
lcd.setCursor(0,1);
lcd.print("DITERIMA");
digitalWrite(35,HIGH); // LED2
delay(1500);
digitalWrite(35,LOW); //LED2
delay(3000);
lcd.clear();
lcd.print("TERIMA KASIH");
}
{
if(digitalRead(40)==HIGH) // when push button 1 pressed
digitalWrite(27,HIGH);
else
digitalWrite(27,LOW);
}
{
if(digitalRead(41)==HIGH) // when push button 2 pressed
{
digitalWrite(27,LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("HAD TUKARAN");
lcd.setCursor(0,1);
lcd.print("HANYA RM1.00");}
}
{
if(digitalRead(42)==HIGH); // // when push button 3 pressed
lcd.clear();
lcd.setCursor(0,0);
lcd.print("MESIN KEHABISAN");
lcd.setCursor(0,1);
lcd.print("DUIT SYILING");
}} }