How to switch to an other configuration

Part 1

combination SwitchA SwitchB led1 led2 led3 led4

1 Off Off O X X O

2 On Off X O O O

3 Off On O O O X

4 On On X X X X

Part 2

combination SwitchA SwitchB led1 led2 led3 led4

1 Off Off X O O X

2 On Off O O O X

3 Off On X O O O

4 On On * * * *

O = Low
X = High

  • = blinking led

The program needs to start with part 1 you can press any combination but when you press combination 4 it needs to go too part 2.
In part 2 you can also press any combination but when you press combination 4 it needs to go back to part 1.

The problem is that i cant switch from part 1 to part 2.

I hope you can help me.

_20150627_Examenvraag_Maurice_versie_3.ino (1.94 KB)

Put the code that is now in loop() into a function called loopA() and create a new loop() function that is something like this

void loop() {
   selection = digitalRead(selectionSwitchPin);
   if (selection == HIGH) {
      loopA();
   }
   else {
      loop2();
   }
}

That is probably a bit too simple - but it will give you the idea.

...R