I am making a project where if the push button is pressed, the LCD screen will show a message. But with many trial and errors, it doesn't give the right result.
Here is the code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define BUTTON 7
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(BUTTON, INPUT);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 0);
// print the number of seconds since reset:
lcd.print("Press Button");
lcd.setCursor(0,1);
lcd.print("to make COFFEE");
if (digitalRead(BUTTON) == HIGH) {
lcd.clear();
lcd.print("SENT TO MACHINE");
}
}

