LCD & button to change lcd.write

I am new to programming and have made a few Arduino projects which have been a great way to learn.

I have a project which requires a button to advance through various lcd.write commands. i.e: each time a button is pressed the LCD displays the next message needed for a basic instructions interface.

Another button then needs to start the process from the beginning again.

I assume this would use interrupts but I am yet to find any examples or tutorials.

I assume this would use interrupts

There is no need to complicate things so forget about using interrupts.

Here is some pseudocode to give you some ideas

declare an array of pointers to the lines of text
declare a counter variable and set it to zero

start of loop()
  if button 1 is pressed increment the counter variable
    if the counter variable is greater than the maximum or button 2 is pressed
      reset the counter to zero
    end of if
  end of if
  display the message from the array using the counter as the array index
 end of loop()

Thank you! I will try and get my head around things tonight.

Thanks for the taking to time to help.

  if button 1 is pressed increment the counter variable

To expand on this bit of pseudo code, you'll want to take a look at the state change detection example, as it demonstrates how to act on the transition of a switch being not pressed to pressed, rather than just seeing if it is pressed down.

Good point Arrch. I was trying to keep it simple, but state change detection will certainly be needed as may debouncing. It would have been better if I had said

when button 1 changes from not pressed to pressed increment the counter variable

if you are going to read the button value and want to debounce it easily, then i have got something that you may likehttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/tree/master/Bounce2... it is very easy to use and if you have any problems with it then you can always ask... :)

arduino2399: if you are going to read the button value and want to debounce it easily, then i have got something that you may likehttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/tree/master/Bounce2... it is very easy to use and if you have any problems with it then you can always ask... :)

try first the state change as mentioned above:

like this:

byte pressed = digitalRead(buttonPin);
  if (pressed)
  {
    if (pressed != lastPressed)
    {
      // do your thing here
    }
  }
  lastPressed = pressed;