Programming Question on how to make a sequence stop and wait for the user's input

Hi, I have a question. I'm developing a project in which the goal is to display 7 sequences that are powers of 2, starting at 2^0, up to the maximum power appropriate to the range of values. The Arduino has to guess the number thought by the user and display it at the end. The user has 2 buttons (YES and NO) to say if their number is in the sequence shown. At this point I've already managed to code the sequences but I don't know how to make the sequence wait for the user's INPUT for only when it is given, to show the next sequence.

Try using a state for each button.
You can do nothing while the states remain unchanged except check the buttons. Then, when either state changes you can take the next action.
You may need to switch from a while loop to millis() for timing.

I think you are looking for something like:

https://forum.arduino.cc/t/waiting-for-user-input/311750/6

it is not really clear to me how the program should behave.
easiest way to describe this is to write down an example:

I'll try it: User thinks of 2^5 (which is 32)

Arduino is guessing 2^3 (which is eight) shows the 8
User presses the "NO-button"

Arduino guesses new 2^6 (which is 64)
User presses the "NO-button"

Arduino guesses new 2^5 (which is 32)
User presses the "YES-button"

That's what I understand from your description. I guess you mean something different
so describe it in a similar way

as long as the wanted behaviour of the code is unclear any suggestion might lead into the wrog direction

EDIT:

You should post your full code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Hello
I propose to study the IPO model before start with coding.

Not quite. I think I managed to explain it better at the #6 comment

???

still not clear to me.
Change your explaining style to writing down an example with example-numbers for everything.
Number assumed
number "chosen by the code"
way of how the chosen number is presented to the player
writing down the content of variables and explicitly writing calculations with the example-numbers = real digits

each time the status of the LEDs changes write the status of all LEDs
suggestion

12345678
oXooooXX

meaning: LEDs with an "X" are switched on

If you prefer waiting for a mathematical and informatic geniuos that understands your description well just another and different way to receive answers

best regards Stefan