Multiple buttons

Hello I am making a simple patch for the ardunio.

I am wondering how to have more then one button working on the arduino.

How do I write this code?

Thanks :grin:

Take the code for one button (switch), and repeat it, but change the spelling of the variables.

(what's a patch?)

Look at the Examples->Digital->Button example.

In place of 'buttonPin' you can use 'buttonPin1", 'buttonPin2', 'buttonPin3'... Use one digital input pin per button.

Arduino-speak quiz.

Sketch:Program :: Button:Switch
Button:Switch :: Patch:_________ ?


Thank you for your replies, this has helped. Sorry for the use of the word patch, wrong use of wording.

Dose anyone work with max msp and arduino. I am working on a project where I am using 3 buttons to control levels in max. Has anyone done this before or can you give any tips.


Are you sure you mean buttons or three twist knobs (potentiometers)? Describe your user interface to us in more detail.

Well, you can access the buttons one after the other in loop() with some kind of state machine system, like code that implements "If ButtonOne state was up and is now down, call the function that activates ButtonOne's code, then set ButtonOne's state to down."

Or, you could use a simple event manager like this one on my blog:

You don't have to use that... but the blog entry has a lot of info about events like button pushes you might find useful.

Just trying to help.