Code Issues with buttons

i want my buttons to activate their respective leds, but i cant seem to have both buttons in the same unit, any help? i used #define because it was something i saw on a vid, im just trying to make the values work via precise presses, aka, press 1 button first, then the other one

and if yall can help me reset every wrong button press that be great, but its optional

#define LED_PIN_1 2
#define LED_PIN_2 5
#define BUTTON_PIN_1 4
#define BUTTON_PIN_2 3

byte lastButtonState;
byte ledState = LOW;

unsigned long lastTimeButtonStateChanged = millis();
unsigned long debounceDuration = 50;

void setup () {
  pinMode(LED_PIN_1, OUTPUT);
  pinMode(LED_PIN_2, OUTPUT);
  pinMode(BUTTON_PIN_1, INPUT);
  pinMode(BUTTON_PIN_2, INPUT);
  lastButtonState = digitalRead(BUTTON_PIN_1);
  lastButtonState = digitalRead(BUTTON_PIN_2);
}

void loop() {
  if (millis() - lastTimeButtonStateChanged >= debounceDuration) {
    byte buttonState = digitalRead(BUTTON_PIN_1);
    if (digitalRead(BUTTON_PIN_1 = LOW)) {
      do (digitalRead(BUTTON_PIN_2 = LOW);
          
      if (buttonState != lastButtonState) {
        lastTimeButtonStateChanged = millis();
        lastButtonState = buttonState;
        if (buttonState == LOW) {
          if (ledState == HIGH) {
            ledState = HIGH;


          }
          else {
            ledState = HIGH;
          }

          digitalWrite(LED_PIN_1, ledState);
          digitalWrite(LED_PIN_2, ledState);
        }
      }
          }
          }
          }

  

Welcome to the forum

if (digitalRead(BUTTON_PIN_1 = LOW))

Check the syntax of digitalRead() as you have used it incorrectly

do (digitalRead(BUTTON_PIN_2 = LOW);

and here too. There is also a problem with how you are trying to use do/while such as not having a while

...also, mismatched parentheses on Line 25.

And your if...else strucure doesn't seem to serve any purpose, as both conditions have the same result.

It is not clear what you are trying to do. It seems you want to control 2 LEDs with 2 buttons. You only have one variable for the state and time. You will need one for each LED button pair.

Also this does nothing if ledState is HIGH. Did you mean to toggle it?

            if (ledState == HIGH) {
              ledState = HIGH;


            }
            else {
              ledState = HIGH;
            }

its a button press, i want it to stay high until all other values are pressed, and if i cant get all the values working, i cant make the ending toggle, so i keep it like that for now

i know, its a temporary fix for the leds to stay on

Your code only works (excluding the errors that have marked you) for one button.
You have a single set of variables for both buttons and due to the program flow they always refer to button 2.

im trying to make BUTTON_PIN_1 be toggled first to then make BUTTON_PIN_2 work as intended, and i figured to try to use do as a statement to be triggered later

If you want to control the two LEDs independently, how come you only have a single shared variable for ledState?

Also, in your own words, what is this intended to accomplish?

if (digitalRead(BUTTON_PIN_1 = LOW)) {
      do (digitalRead(BUTTON_PIN_2 = LOW);

how do i fix that issue, the digitalRead() function is on the fritz and i dont know how to fix it

Look at the example and explanation here:

And here:

https://docs.arduino.cc/built-in-examples/basics/DigitalReadSerial/

im fairly new to this as you can see, that piece of code is to make both buttons work independently from each other, or at least making the value work as a "i press button 1 to activate button 2"

Use arrays to manage the states of each button or simplify your life and use a library, there are for all tastes and all of them are excellent.

i did look at it, but its for a value, and i just need the led to stay on and the other to stay off

When you looked at it, did you see any example code that resembled the following statement?

digitalRead(pushButton = LOW)

i barely use the library, well, i am new so the library is my second unexplored challenge, but its mostly because im using tinkerkad as my sim to run all the code, and that library is smaller and has nothing im looking for frankly

the closest is val = digitalRead(inPin)

OK, so if you're new, it's best not to make up your own code syntax by improvising.

You can use your own variable names (.e.g., BUTTON_PIN_1 instead of pushButton or inPin), but don't insert random operators (=) where they don't belong.

makes sense, i just though i can use the do statement alone, since i dont need a while statement, or thats what i thought

This has a vanishingly low probability of being true. It is more likely to be a wiring error, a bad switch or a burnt-out pin on your Arduino.

And what means this:

There is no later. Programs run lines sequentially, there is no statement that means get around to this later. When or how 'xactly should it be executed?

a7