Problem with toggle switch

Hi !
I know, that can be a naive question, but, als beginner what kind a question can i use ? :slight_smile:

I'm trying to program my Arduino ONE. I have 4 switches on digital inputs wchich should do something like this :

  1. switch 1 on (click) - make relay 1 on and after 0.5sec relay 5 on after 1 second both off
  2. switch 1 ONE MORE TIME on (click)- make relay 1 on and after 0.5sec relay 6 on after 1 second both off
    after this, when i click switch 1 on should do program (1) again and so on...

same setting i need for switch 2,3 and 4 also together with relays 5 and 6.
I'm sitting allready few hours and it goes not forward :frowning:

Hardware :
Arduino UNO R3
8 Relay Module

Please help :slight_smile:
Martin.

Hi

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Can you please post a copy of your sketch, using code tags.

It will help a lot.

Tom.... :slight_smile:

one way would be to just use a lot of IF statements.

what is not clear is what you want to happen if switch 1 and 3 are pressed at the same time ?

if (sw1 =HIGH ) || (sw2 =HIGH ) || (sw3 =HIGH ) || (sw4 =HIGH ) || ( sw5 =HIGH )
switchpressed = high
else
swithpressed - LOW

if switchpressed == HIGH
// you need to add checking that switch is not held, only pressed - see debounce
digitalWrite(relay1, HIGH)
delay (500)
digitalWrite(relay1,LOW)
delay (500)
relaycount ++1
if relaycount > 5
relaycount = 1 // this will let you go from 5 to 1
digitalWrite (relaycount , HIGH)
delay (500)
digitalWrite (relaycount , LOW)
delay (500)

// you need to add your timing, see blink without delay.

in this case, you may want to use delay to ignore any other inputs and lock out all inputs while the unit is timing.

since you said you will use the same setting for any switch, all you need to do is create one line that tests to see if any switch is pressed.

I gave you clues. you have to write the code yourself.

Hi all :wink:
I pretty sure, that is my first shematic, so please forgive me mistakes :wink:
Now you can see how my circuit looks like. Now about function:
What it should do is to steering RC controller (433Mhz power outlet supply) wchich will be connected to those relays. Now, i've tried both programm possibilities (toggle and press-and-hold) with same result - i know to less about programming.
Those 4 switch are on my Home automation actor, they can be also programmed, i can for ex. say that one switch have to be closed for 1 or more seconds. Unfortunetly, i cannot write good programm yet :frowning:
So, please don't hesitate to ask, if something is not clear !
Greetings,
M.

...to dave...

Switches 1-4 will activate one of four power unit, relay 5 and 6 have to send signal "on" and "off"
Swtches should not be pressed on same time :slight_smile: Every power unit have to be controlled separetly :slight_smile:
M.