Push button Switches Won't work

Total noob; sooo new, that even digging through the forums is hard to comprehend. So apologies and thanks you's right away.

This program is a beginner project that when the one button is pushed it activates the motor for 4 seconds and then changes the state of the leds. when a second button is pressed it does the reverse.

I modified a simple push button switch from the reference section here but can't get them to actually work.

I've run the check in the IDE and it's not throwing any errors its just not working.

tinkerCAD link: Circuit design Copy of Launch Bay Door Control | Tinkercad

Please HALP! lol

J

Did you use INPUT_PULLUP or add a pullup or pulldown resistor to the button?

OOPS forgot the the code if you don’t use tinkerCAD.
<// C++ code
//

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int MOTOR_CLOSE=11;//"motor_forward" from other
const int MOTOR_OPEN=10;//"motor_back" from other
int RED_LIGHT= 14;
int ORANGE_LIGHT= 15;
int GREEN_LIGHT= 16;
const int BUTTON_OPEN= 9;
const int BUTTON_CLOSE= 8;
int buttonStateONE = 0;
int buttonStateTWO = 0;


void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(MOTOR_CLOSE, OUTPUT);
  pinMode(MOTOR_OPEN, OUTPUT);
  pinMode(RED_LIGHT, OUTPUT);
  pinMode(ORANGE_LIGHT, OUTPUT);
  pinMode(GREEN_LIGHT, OUTPUT);
  pinMode(BUTTON_OPEN, INPUT);
  pinMode(BUTTON_CLOSE, INPUT);
  
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, HIGH);
  lcd.setCursor(1,0);
  lcd.print("Comand&Control");
  lcd.setCursor(0,1);
  lcd.print("Launch Bay Doors");
  delay(3000);//CHANGE ME FOR FINAL TIMING 3-6s?!!!!
  lcd.clear();
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(500);//CHANGE ME FOR FINAL TIMING 2s?!!!!
  
}

void loop()
{
  buttonStateONE = digitalRead(BUTTON_OPEN);
  buttonStateTWO = digitalRead(BUTTON_CLOSE);

  while (RED_LIGHT=HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(2000);
  
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 1 to Open");
  delay(3000);
}

if (buttonStateONE == HIGH) {
  
  lcd.clear();
  lcd.print("OPENING!");
  digitalWrite(MOTOR_OPEN, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**OPEN**");
  digitalWrite(MOTOR_OPEN, LOW);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, HIGH);
  delay (1500);
}
  while (GREEN_LIGHT=HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("***OPEN***");
  delay(2000);
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("GO GO GO");
    delay(1500);
    
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 2 to Close");
  delay(3000);
}
if (buttonStateTWO == HIGH) {
  
  lcd.clear();
  lcd.print("CLOSING!");
  digitalWrite(MOTOR_OPEN, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**CLOSED**");
  digitalWrite(MOTOR_OPEN, LOW);
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  delay (1500);
}
  
  
}

push down resistor I believe.

And when you did post it uou did not use code tags

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

what is happening when you press the button? nothing?

nothing.

sorry i thought these were the tags “<>”

…an unrelated problem is my eyes are burning out. reading on my laptop is becoming very problematic.

are the leds lighting up?

  while (GREEN_LIGHT = HIGH)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(3, 1);
    lcd.print("***OPEN***");
    delay(2000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("GO GO GO");
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(0, 1);
    lcd.print("Press 2 to Close");
    delay(3000);
  }

= does not do a comparison

Also, as GREEN_LIGHT does not change in this while loop how will it ever end ?

the void setup works exactly like I want it to, and the fist 'while' loop also works. its after where

if (buttonStateONE == HIGH) {

lcd.clear();
lcd.print("OPENING!");
digitalWrite(MOTOR_OPEN, HIGH);
digitalWrite(RED_LIGHT, LOW);
digitalWrite(ORANGE_LIGHT, HIGH);
digitalWrite(GREEN_LIGHT, LOW);
delay(4000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Launch Bay Doors");
lcd.setCursor(1,1);
lcd.print("OPEN");
digitalWrite(MOTOR_OPEN, LOW);
digitalWrite(RED_LIGHT, LOW);
digitalWrite(ORANGE_LIGHT, LOW);
digitalWrite(GREEN_LIGHT, HIGH);
delay (1500);
}

Both while loops use = instead of ==
They don't work

No code tags again !

ack. my bad. sorry again.

wrong button.

Oh my goodness. Thank you;; that's progress! The whole loop runs now.

What im trying to get it to do now:
is getting it to stop between 'open' and close.

And I straight up am very confused as to which control command does this.

// C++ code
//

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int MOTOR_CLOSE=11;//"motor_forward" from other
const int MOTOR_OPEN=10;//"motor_back" from other
int RED_LIGHT= 14;
int ORANGE_LIGHT= 15;
int GREEN_LIGHT= 16;
const int BUTTON_OPEN= 9;
const int BUTTON_CLOSE= 8;
int buttonStateONE = 0;
int buttonStateTWO = 0;


void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(MOTOR_CLOSE, OUTPUT);
  pinMode(MOTOR_OPEN, OUTPUT);
  pinMode(RED_LIGHT, OUTPUT);
  pinMode(ORANGE_LIGHT, OUTPUT);
  pinMode(GREEN_LIGHT, OUTPUT);
  pinMode(BUTTON_OPEN, INPUT);
  pinMode(BUTTON_CLOSE, INPUT);
  
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, HIGH);
  lcd.setCursor(1,0);
  lcd.print("Comand&Control");
  lcd.setCursor(0,1);
  lcd.print("Launch Bay Doors");
  delay(3000);//CHANGE ME FOR FINAL TIMING 3-6s?!!!!
  lcd.clear();
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(500);//CHANGE ME FOR FINAL TIMING 2s?!!!!
  
}

void loop()
{
  buttonStateONE = digitalRead(BUTTON_OPEN);
  buttonStateTWO = digitalRead(BUTTON_CLOSE);

  while (RED_LIGHT==HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(2000);
  
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 1 to Open");
  delay(3000);
}

if (buttonStateONE == HIGH) {
  
  lcd.clear();
  lcd.print("OPENING!");
  digitalWrite(MOTOR_OPEN, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**OPEN**");
  digitalWrite(MOTOR_OPEN, LOW);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, HIGH);
  delay (1500);
}
  while (GREEN_LIGHT==HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("***OPEN***");
  delay(2000);
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("GO GO GO");
    delay(1500);
    
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 2 to Close");
  delay(3000);
}
if (buttonStateTWO == HIGH) {
  
  lcd.clear();
  lcd.print("CLOSING!");
  digitalWrite(MOTOR_OPEN, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**CLOSED**");
  digitalWrite(MOTOR_OPEN, LOW);
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  delay (1500);
}
  
  
}

GREEN_LIGHT is a pin, you will have to read it to know if it's high or low; that will work on AVR based Arduinos, not sure about others.

ok this is close I think; I just need to figure out how to make an 'int' at the very beginning work with the digitalREAD

// C++ code
//

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int MOTOR_CLOSE=11;//"motor_forward" from other
const int MOTOR_OPEN=10;//"motor_back" from other
int RED_LIGHT= 14;
int ORANGE_LIGHT= 15;
int GREEN_LIGHT= 16;
const int BUTTON_OPEN= 9;
const int BUTTON_CLOSE= 8;
int buttonStateONE = 0;
int buttonStateTWO = 0;


void setup()
{
  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(MOTOR_CLOSE, OUTPUT);
  pinMode(MOTOR_OPEN, OUTPUT);
  pinMode(RED_LIGHT, OUTPUT);
  pinMode(ORANGE_LIGHT, OUTPUT);
  pinMode(GREEN_LIGHT, OUTPUT);
  pinMode(BUTTON_OPEN, INPUT);
  pinMode(BUTTON_CLOSE, INPUT);
  
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, HIGH);
  lcd.setCursor(1,0);
  lcd.print("Comand&Control");
  lcd.setCursor(0,1);
  lcd.print("Launch Bay Doors");
  delay(3000);//CHANGE ME FOR FINAL TIMING 3-6s?!!!!
  lcd.clear();
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(500);//CHANGE ME FOR FINAL TIMING 2s?!!!!
  
}

void loop()
{
  buttonStateONE = digitalRead(BUTTON_OPEN);
  buttonStateTWO = digitalRead(BUTTON_CLOSE);
    RED_LIGHT = digitalread (RED_LIGHT);
    GREEN_LIGHT = digitalread (GREEN_LIGHT);

  while (RED_LIGHT==HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("**CLOSED**");
  delay(2000);
  
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 1 to Open");
  delay(3000);
}

if (buttonStateONE == HIGH) {
  
  lcd.clear();
  lcd.print("OPENING!");
  digitalWrite(MOTOR_OPEN, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**OPEN**");
  digitalWrite(MOTOR_OPEN, LOW);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, HIGH);
  delay (1500);
}

  while (GREEN_LIGHT==HIGH){  
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(3,1);
  lcd.print("***OPEN***");
  delay(2000);
    
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("GO GO GO");
    delay(1500);
    
  lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(0,1);
  lcd.print("Press 2 to Close");
  delay(3000);
}
if (buttonStateTWO == HIGH) {
  
  lcd.clear();
  lcd.print("CLOSING!");
  digitalWrite(MOTOR_CLOSE, HIGH);
  digitalWrite(RED_LIGHT, LOW);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, LOW);
  delay(4000);
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Launch Bay Doors");
  lcd.setCursor(1,1);
  lcd.print("**CLOSED**");
  digitalWrite(MOTOR_CLOSE, LOW);
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  delay (1500);
}
  
  
}

I did this and now obviously there is a conflict; how can i serrate them? and still have the pin as an output and read its own state?

// C++ code
//

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int MOTOR_CLOSE=11;//"motor_forward" from other
const int MOTOR_OPEN=10;//"motor_back" from other
const int RED_LIGHT= 14;
const int ORANGE_LIGHT= 15;
const int GREEN_LIGHT= 16;
const int BUTTON_OPEN= 9;
const int BUTTON_CLOSE= 8;
int buttonStateONE = 0;
int buttonStateTWO = 0;
int RED_LIGHT= 0;
 int GREEN_LIGHT=0;

void setup()

You can read the state of an output pin using digitalRead()

Awesome! Thank you.

this is what I came up; with a lttle more help from my prof.


// C++ code

//

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int MOTOR_CLOSE = 11;  //"motor_forward" from other
const int MOTOR_OPEN = 10;   //"motor_back" from other
const int RED_LIGHT = 14;
const int ORANGE_LIGHT = 15;
const int GREEN_LIGHT = 16;
const int BUTTON_OPEN = 9;
const int BUTTON_CLOSE = 8;
int buttonStateONE = 0;
int buttonStateTWO = 0;
int DOOR_STATUS=0;      //Closed=0, Opening =1, Closing=2, Open=4

 
void setup() {

  Serial.begin(9600);
  lcd.begin(16, 2);
  pinMode(MOTOR_CLOSE, OUTPUT);
  pinMode(MOTOR_OPEN, OUTPUT);
  pinMode(RED_LIGHT, OUTPUT);
  pinMode(ORANGE_LIGHT, OUTPUT);
  pinMode(GREEN_LIGHT, OUTPUT);
  pinMode(BUTTON_OPEN, INPUT);
  pinMode(BUTTON_CLOSE, INPUT);
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, HIGH);
  digitalWrite(GREEN_LIGHT, HIGH);
  lcd.setCursor(1, 0);
  lcd.print("Comand&Control");
  lcd.setCursor(0, 1);
  lcd.print("Launch Bay Doors");
  delay(3500);  //CHANGE ME FOR FINAL TIMING 3-6s?!!!!

  lcd.clear();
  digitalWrite(RED_LIGHT, HIGH);
  digitalWrite(ORANGE_LIGHT, LOW);
  digitalWrite(GREEN_LIGHT, LOW);
  lcd.setCursor(0, 0);
  lcd.print("Launch Bay Doors");
  lcd.setCursor(2, 1);
  lcd.print("***CLOSED***");
  delay(2500);  //CHANGE ME FOR FINAL TIMING 2s?!!!!
}

void loop() {

  while (DOOR_STATUS==0) {//while the door is closed
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(2, 1);
    lcd.print("***CLOSED***");
    delay(2000);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(0, 1);
    lcd.print("Press 1 to Open");
    unsigned long start=millis();
    while(digitalRead(BUTTON_OPEN==LOW)&&(millis()-start<300));

    if (digitalRead(BUTTON_OPEN) == HIGH) {
      digitalWrite(RED_LIGHT, LOW);
      DOOR_STATUS=1;    //change state to opening
    }
  }
 
  if (DOOR_STATUS=1) {  //the door is opening

    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("***OPENING!***");
    digitalWrite(MOTOR_OPEN, HIGH);
    digitalWrite(RED_LIGHT, LOW);
    digitalWrite(ORANGE_LIGHT, HIGH);
    digitalWrite(GREEN_LIGHT, LOW);
    delay(4000);//"door" takes 4s to open
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(3, 1);
    lcd.print("***OPEN***");
    digitalWrite(MOTOR_OPEN, LOW);
    digitalWrite(RED_LIGHT, LOW);
    digitalWrite(ORANGE_LIGHT, LOW);
    digitalWrite(GREEN_LIGHT, HIGH);
    delay(2000);

    DOOR_STATUS=4;   //the door is open
  }

  while (DOOR_STATUS==4) {  //while the door is fully open

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(3, 1);
    lcd.print("***OPEN***");
    delay(2000);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("*  STARBUCK IS *");
    lcd.setCursor(0, 1);
    lcd.print("CLEAR FOR LAUNCH");
    delay(2500);
    lcd.clear();
    lcd.setCursor(3, 1);
    lcd.print("*GO GO GO*");
    delay(2000);

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(0, 1);
    lcd.print("Press 2 to Close");
     unsigned long start=millis();
    while(digitalRead(BUTTON_CLOSE==LOW)&&(millis()-start<300));
    
    if(digitalRead(BUTTON_CLOSE)==HIGH){
      DOOR_STATUS=3; //the door is closing
   //add additional LED on/off here
  }
  }

  if (DOOR_STATUS=3) {  //if the door is closing

    lcd.clear();
    lcd.setCursor(1,0);
    lcd.print("***CLOSING!***");
    digitalWrite(MOTOR_CLOSE, HIGH);
    digitalWrite(RED_LIGHT, LOW);
    digitalWrite(ORANGE_LIGHT, HIGH);
    digitalWrite(GREEN_LIGHT, LOW);
    delay(4000);//"door" takes 4s to close.
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Launch Bay Doors");
    lcd.setCursor(3, 1);
    lcd.print("**CLOSED**");
    digitalWrite(MOTOR_CLOSE, LOW);
    digitalWrite(RED_LIGHT, HIGH);
    digitalWrite(ORANGE_LIGHT, LOW);
    digitalWrite(GREEN_LIGHT, LOW);
    delay(1500);
    DOOR_STATUS=0;   //the door is closed
  }
}

if (DOOR_STATUS=1)
. . .
if (DOOR_STATUS=3)

Again ?

You need to try much harder.