I have built a secret knock sensor based on the Steve Hoefer script (Secret Knock Detecting Door Lock) for the lab at work.
I'd like to use a switch to change the defined array at the start.
So, when the switch is HIGH or 1 the secretCode array changes to:
1)
int secretCode[maximumKnocks] = {70, 25, 25, 50, 50, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
And when it is LOW or 0 it uses the original stated below:
2)
int secretCode[maximumKnocks] = {50, 25, 25, 50, 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Initial setup: "Shave and a Hair Cut, two bits."
The reason for this is that I'd like a different knock at the weekend for a different team without having to program it at the end of Friday and I thought a switch would be great.
In the setup I've included:
3)
int stateWeekend = digitalRead(switchOne);
if (stateWeekend == 1) {
Serial.println("Weekend"); //debug
// array change
}
Where I've commented for an array change, I have tried everything I'm aware of. By defining each one e.g. secretCode[0] = 70; secretCode[1] 25; e.t.c. within the setup and loop, as well as a complete array as above in code 1, without the int definition, with maximumKnocks as [] and so on... I've ran out of ideas.
I have been reading and trying different things but to my understanding, if I took the array out and placed it in the set up, the script wouldn't work.