Need help to make push buttons work

Good afternoon. I’m new at Arduino programming and I’m working at my first solo project.

I’m trying to make something related with LEDs, LCD and … push buttons.

Leds work, as well as the LCD, but whenever I press the push buttons, nothing happens. I would like to ask if its a problem of coding.

This is my code:

#include <LiquidCrystal.h>

int switchstate1 = 0;
int switchstate2 = 0;
LiquidCrystal lcd(1, 0, 13, 12, 11, 10);

void setup() {
// LEDs are outputs and switch pins are input
pinMode(2, INPUT); //yellow button (1)
pinMode(3, INPUT); //red button (2)

pinMode(4, OUTPUT);//1st red LED
pinMode(5, OUTPUT);//2nd red LED
pinMode(6, OUTPUT);//1st yellow LED
pinMode(7, OUTPUT);//2nd yellow LED
pinMode(8, OUTPUT);//1st green LED
pinMode(9, OUTPUT);//2nd green LED

}

void loop() {
// reads the value of the switch
switchstate1 = digitalRead(2);
switchstate2 = digitalRead(3);
if (switchstate1 == LOW) {
digitalWrite(4, LOW); // turn the red LED on pin 4 off
digitalWrite(5, LOW); // turn the red LED on pin 5 off
digitalWrite(6, LOW); // turn the yellow LED on pin 6 off
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, LOW); // turn the green LED on pin 8 off
digitalWrite(9, LOW); // turn the green LED on pin 9 off

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
lcd.print(“Ready to depart?”);

}
if (switchstate1 == HIGH) {
digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, LOW); // turn the red LED on pin 5 off
digitalWrite(6, LOW); // turn the yellow LED on pin 6 off
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, LOW); // turn the green LED on pin 8 off
digitalWrite(9, LOW); // turn the green LED on pin 9 off
delay(1000);

digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, HIGH); // turn the red LED on pin 5 on
digitalWrite(6, LOW); // turn the yellow LED on pin 6 off
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, LOW); // turn the green LED on pin 8 off
digitalWrite(9, LOW); // turn the green LED on pin 9 off
delay(1050);

digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, HIGH); // turn the red LED on pin 5 on
digitalWrite(6, HIGH); //turn the yellow LED on pin 6 on
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, LOW); // turn the green LED on pin 8 off
digitalWrite(9, LOW); // turn the green LED on pin 9 off
delay(1050);

digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, HIGH); // turn the red LED on pin 5 on
digitalWrite(6, HIGH); // turn the yellow LED on pin 6 on
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, LOW); // turn the green LED on pin 8 off
digitalWrite(9, LOW); // turn the green LED on pin 9 off
delay(1500);

digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, HIGH); // turn the red LED on pin 5 on
digitalWrite(6, HIGH); // turn the yellow LED on pin 6 on
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, HIGH); // turn the green LED on pin 8 on
digitalWrite(9, LOW); // turn the green LED on pin 9 off
delay(1999);

digitalWrite(4, HIGH); // turn the red LED on pin 4 on
digitalWrite(5, HIGH); // turn the red LED on pin 5 on
digitalWrite(6, HIGH); // turn the yellow LED on pin 6 on
digitalWrite(7, LOW); // turn the yellow LED on pin 7 off
digitalWrite(8, HIGH); // turn the green LED on pin 8 on
digitalWrite(9, HIGH); // turn the green LED on pin 9 on
delay(2789);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
lcd.print(“Ready to depart?”);

}

lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 0);

if (switchstate2 == HIGH) {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
lcd.print(“Departing in…”);
delay(2000);

lcd.print(“5”);
delay(1000);

lcd.print(“4”);
delay(1000);

lcd.print(“3”);
delay(1000);

lcd.print(“2”);
delay(1000);

lcd.print(“1”);
delay(1000);

lcd.print(“Welcome to 1789”);
}

}

I really would use some help.

Thank you,
Pedro Santos

Time_Machine_with_LCD_-_TEST_2.ino (4.09 KB)

Please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

There is a huge amount of repetition in your code. If you learn how to use arrays you can probably reduce it to 1/4 of its present length.

…R

How's your wiring exactly? (proper circuit diagram please; no unreadable Fritzings)