SwitchCase (Question)

Hi,

I'm working on an Arduino project to measure the comfort of a work place. I need help with the code. I want to execute a different program depending on which button is use.

I've been trying to use the SwitchCase but I have problems with the variable.

I know it's a very basic question but I can't solve it by myself.

Any suggestion will be really helpful

Thanks

You'll need to give details of your hardware: a schematic will be good.... we don't know what you mean by "button", in the sense of not knowing how they're wired.

Do you have many buttons on one analog pin with a resistor ladder perhaps?- or is it a button on each of many digital pins.

Might actually be a case for "if".... "else if".... "else" rather.

Show us what you have...

I don't know how to upload a photo. But the schematic is really simple. I have three buttons, like this:
http://media.apcmag.com/wp-content/uploads/sites/20/2013/03/apcnews2012arduino_logo_mainImage10.jpg10.jpg

Connected to different digital pins (3,4,5 digital pins)

I don't know how to upload a photo

Then read the how to use this forum sticky post at the top of each section.

Connected to different digital pins (3,4,5 digital pins)

How?
Pulling up or down?

Right then you should look at this example and just triplicate the part where it's looking at the buttons and when any button is LOW (LOW means pushed, that's the logic with pullups) do the stuff you need for that button.

Thanks Grumpy_Mike and JimboZA for the tips. I really aprecciate yours replies.

When I say triplicate, don't take me too literally: remember to adjust the pin numbers and variable names :smiley:

pep-f:
Thanks Grumpy_Mike and JimboZA for the tips. I really aprecciate yours replies.

So are you going to answer our questions and get some real help?

Thanks Grumpy_Mike, but my only question was to use the Switch Statement, which i'm going to change for if and else statements.

If I need anything else I will ask on this fantastic forum.