Different Modes and Arduino?

Hello!

I had a question. 

I want to have like 5 buttons and every time I press one button it runs a certain block of code over and over until I press another button. This way I can have different modes etc. mode 1, mode 2. . .
Can somebody help me with the code please?

Thanks

sort by: active | newest | oldest
1-10 of 20Next »
robobot31122 months ago

You could possible make a principle code and use the IF statement for example-

void setup(){

enter all constants, variables and stuff here (for all the codes)

}

void loop(){

IF (condition button press 1){

your code

}

ELSE IF (condition button press 2){

your code

}

and so on

the only disadvantage i see is that it takes too much space, but it is possible

Nic-SMD3 months ago

Hello,

I need to make a project but my zero knowledge in programming does not allow me to go far.. For someone with the knowledge and experience may be a code for children :)

My code needs to have three different modes just to activate two relays in a different way at each mode.

Can anyone help please?? I will send a brief description of what I need.

Anshu AR Nic-SMD3 months ago

Hi,

So, let me get this straight:

You want three modes(inputs) to control two relays. Right?

I can help. Let me know a little more about the input mode. Is it a pushbutton? Also what output(Result) you want for each input.

Nic-SMD Anshu AR3 months ago

Hi,

Thanks a lot for offering to help me on that. I can send you a brief description via email if you like to take a full view off what I need.

Anshu AR Nic-SMD3 months ago

Alright go ahead.

You can send me the details through personal message on my instructables account.

Nic-SMD Anshu AR3 months ago
take a look at this
Anshu AR Nic-SMD3 months ago

Alright!

Nic-SMD Anshu AR3 months ago

Hi Anshu,

Any news? Do you think that you can figure out something of this?

Anshu AR Nic-SMD3 months ago

Hi,

Sorry that setup turned out to be lot complicated (for me)

I can write a program to perform a simpler function.

The main obstacle is that the Arduino needs to store some data on which button was pressed earlier.

Apart from this everything is cool.

I can code for a setup that turns on or off the relays and even display the outputs and inputs on the LCD.

But, nothing that complex. Sorry! :(

Nic-SMD Anshu AR3 months ago

First of all I am really appreciate your time.

What I have seen so far is that many use multiple void () functions or what they call them. So 3 different void(), one for each mode. And then you call the in void loop() or in a main void(). And I think a counter function to count the times that the button has pressed.

Why Arduino has to know what button has pressed earlier? I am asking because after you select and finish a mode it has to go back in the beginning and can select any mode you want, even the same as previews.

1-10 of 20Next »