Hi, I am trying to work with a lcd screen, pushbutton, and LED. When I upload my code the "Button is waiting to be pushed" text constantly repeats itself. I was hoping someone could help me make it so it only displays once. When the button gets pressed it should switch the text to "Button has been pressed, LED should be on" and when it is not pressed go back to "Button is waiting to be pushed. I hope I posted this correctly as it is my first time posting to the forum. Thank you.
#include <LCDWIKI_GUI.h>
#include <LCDWIKI_KBV.h>
LCDWIKI_KBV my_lcd(ILI9486, A3, A2, A1, A0, A4);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define BUTTON_PIN 53
#define LED_PIN 51
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
my_lcd.Init_LCD();
Serial.println(my_lcd.Read_ID(), HEX);
// Welcome code for the first screen shown
my_lcd.Fill_Screen(RED);
my_lcd.Set_Text_colour(CYAN);
my_lcd.Set_Text_Size(3);
my_lcd.Print_String("Hello Joey!", 65, 40);
delay(1000);
// Another test of the screen chage
my_lcd.Set_Text_colour(CYAN);
my_lcd.Set_Text_Size(3);
my_lcd.Print_String("Senior Design", 35, 75);
delay(1000);
// Setting pin devices for the project
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Looks to see if the button is pushed and turns on the led
if (digitalRead(BUTTON_PIN) == HIGH) {
digitalWrite(LED_PIN, HIGH);
my_lcd.Set_Text_colour(CYAN);
my_lcd.Set_Text_Size(2);
my_lcd.Print_String("Button has been "
"\npushed, LED should be on",
5, 115);
}
// Looks to see if the button is not pushed, displays the button is ready to be pushed
else {
digitalWrite(LED_PIN, LOW);
my_lcd.Fill_Screen(RED);
my_lcd.Set_Text_colour(CYAN);
my_lcd.Set_Text_Size(2);
my_lcd.Print_String("Button is waiting"
"\nto be pushed",
5, 115);
}
}