The program code is completed and remained one issue where I need your help,
It is when you press any push button switch more than once will be repeated appearance switch number on the screen.
I want to show switch number Once even that was compressed more than once.
Thanks
this sample of the
code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int Buzerpin = 13; //buzzer
const int buttonPin = 6;
const int buttonPin2 = 7;
const int buttonPin3 = 8;
const int buttonPin4 = 9;
int buttonState = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int lastButtonState = 0;
int lastButtonState2 = 0;
int lastButtonState3 = 0;
int lastButtonState4 = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
lcd.print("SAMAWA HOSPITAL");
delay(5000);
lcd.clear();
pinMode(buttonPin, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(Buzerpin, OUTPUT);
Serial.begin(9600);
}
void loop() {
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
digitalWrite(Buzerpin, HIGH);
lcd.print("R1");
}
}
lastButtonState = buttonState;
buttonState2 = digitalRead(buttonPin2);
if (buttonState2 != lastButtonState2) {
if (buttonState2 == HIGH) {
digitalWrite(Buzerpin, HIGH);
// Print a message to the LCD.
lcd.print("R2");
lcd.display();
}
}
lastButtonState2 = buttonState2;
buttonState3 = digitalRead(buttonPin3);
if (buttonState3 != lastButtonState3) {
if (buttonState3 == HIGH) {
digitalWrite(Buzerpin, HIGH);
lcd.print("R3");
lcd.display();
}
}
lastButtonState3 = buttonState3;
buttonState4 = digitalRead(buttonPin4);
if (buttonState4 != lastButtonState4) {
if (buttonState4 == HIGH) {
digitalWrite(Buzerpin, LOW);
lcd.clear();
}
}
}