Hello,
I am in my first semester of computer programming and having trouble with assignments relating to the Arduino. I am currently trying to get an LCD screen to switch between displaying my name, my hobby, and my favourite food. I am able to get my name to show up, but the button doesn't register when it's being pushed so it does not go to my hobby, and the serial monitor does not display the corresponding message. Looking for some guidance as to what I'm doing wrong with these buttons? Unfortunately my teacher is no help.
Thanks in advance
#include <LiquidCrystal.h>
//Initialise the Serial LCD.
LiquidCrystal lcd( 12,11,5,4,3,2); //These pin numbers are hard coded in on the serial backpack
//board.
const int button = 8;
int counter = 0;
int buttonState = 0;
int prevButtonState = 0;
void setup()
{
lcd.begin (16,2); //Initialize the LCD.
attachInterrupt(digitalPinToInterrupt(button), button1, CHANGE);
Serial.begin(9600);
}
void loop(){
buttonState = digitalRead(button);
if (buttonState == HIGH) {
Serial.print("test");
for (counter = 0; counter<=4; counter++){
lcd.setCursor(0,0);
lcd.print("Char M");
}
if (buttonState == HIGH) {
Serial.print("test2");
for (counter = 0; counter<=4; counter++){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Cars");
}
}
}
else if (buttonState != prevButtonState) {
if (buttonState == 3) {
Serial.print("test3");
for (counter = 0; counter<=4; counter--){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Meatballs");
}
}
}
}
void button1 (){
Serial.print("test");
lcd.clear();
counter++;
}