PROJECT 1 (2.0!) : LOCK BOX (For 3/26/19)
I expanded upon my original idea to create the LOCK BOX. The goal is for the user to figure out the button path they must take in order to enter the correct password. Then the box opens for a surprise!
The trick to this box, however, is that the button paths change after each successful box open. I have coded a total of 16 button paths, where one is chosen randomly after each successful open. The code allows the user to continue playing in a loop, and the trick to the challenge is a good memory.
Here is a video of me playing with LOCK BOX:
Here are some pictures:
Here is the very long code for LOCK BOX:
#include <Servo.h>
Servo myservo;
const int led1 = 8;
const int led2 = 9;
const int led3 = 10;
const int led4 = 11;
const int but1 = 6;
const int but2 = 2;
const int but3 = 3;
const int but4 = 4;
int randchoice;
int butt1 = 0;
int butt2 = 0;
int butt3 = 0;
int butt4 = 0;
int lbutt1 = 0;
int lbutt2=0;
int lbutt3=0;
int lbutt4=0;
int arr_a[4]={1,2,3,4};
int arr_b[4];
int count = 0;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(but1, INPUT);
pinMode(led2, OUTPUT);
pinMode(but2, INPUT);
pinMode(led3, OUTPUT);
pinMode(but3, INPUT);
pinMode(led4, OUTPUT);
pinMode(but4, INPUT);
myservo.attach(5);
myservo.write(0);
randomSeed(analogRead(0));
randchoice = random(1,16);
}
void loop() {
chooseMap();
butt1 = digitalRead(but1);
butt2 = digitalRead(but2);
butt3 = digitalRead(but3);
butt4 = digitalRead(but4);
if (count >= 4){
checkPass();
}
Serial.print(arr_b[0]);
Serial.print(arr_b[1]);
Serial.print(arr_b[2]);
Serial.println(arr_b[3]);
}
boolean array_cmp(int *a, int *b, int len_a, int len_b){
int n;
// test each element to be the same. if not, return false
for (n=0;n<len_a;n++) if (a[n]!=b[n]) return false;
return true;
}
void checkPass(){
if (array_cmp(arr_a, arr_b, 4, 4) == true){
correctPass();
}
else{
wrongPass();
}
}
void correctPass(){
myservo.write(180);
delay(5000);
myservo.write(0);
memset(arr_b,0,sizeof(arr_b));
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
count=0;
randchoice = random(1,16);
chooseMap();
}
void wrongPass(){
memset(arr_b,0,sizeof(arr_b));
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
count=0;
}
//assign mapping
void chooseMap(){
if(randchoice == 1) {
buttonMap1();
}
else if (randchoice == 2) {
buttonMap2();
}
else if (randchoice == 3) {
buttonMap3();
}
else if (randchoice == 4) {
buttonMap4();
}
else if (randchoice == 5) {
buttonMap5();
}
else if (randchoice == 6) {
buttonMap6();
}
else if (randchoice == 7) {
buttonMap7();
}
else if (randchoice == 8) {
buttonMap8();
}
else if (randchoice == 9) {
buttonMap9();
}
else if (randchoice == 10) {
buttonMap10();
}
else if (randchoice == 11) {
buttonMap11();
}
else if (randchoice == 12) {
buttonMap12();
}
else if (randchoice == 13) {
buttonMap13();
}
else if (randchoice == 14) {
buttonMap14();
}
else if (randchoice == 15) {
buttonMap15();
}
else if (randchoice == 16) {
buttonMap16();
}
}
//Button Mapping Options//
void buttonMap1(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap2(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap3(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap4(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap5(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap6(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap7(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap8(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap9(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap10(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap11(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap12(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap13(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap14(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap15(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap16(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
The trick to this box, however, is that the button paths change after each successful box open. I have coded a total of 16 button paths, where one is chosen randomly after each successful open. The code allows the user to continue playing in a loop, and the trick to the challenge is a good memory.
Here is a video of me playing with LOCK BOX:
Here are some pictures:
Here is the very long code for LOCK BOX:
#include <Servo.h>
Servo myservo;
const int led1 = 8;
const int led2 = 9;
const int led3 = 10;
const int led4 = 11;
const int but1 = 6;
const int but2 = 2;
const int but3 = 3;
const int but4 = 4;
int randchoice;
int butt1 = 0;
int butt2 = 0;
int butt3 = 0;
int butt4 = 0;
int lbutt1 = 0;
int lbutt2=0;
int lbutt3=0;
int lbutt4=0;
int arr_a[4]={1,2,3,4};
int arr_b[4];
int count = 0;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(but1, INPUT);
pinMode(led2, OUTPUT);
pinMode(but2, INPUT);
pinMode(led3, OUTPUT);
pinMode(but3, INPUT);
pinMode(led4, OUTPUT);
pinMode(but4, INPUT);
myservo.attach(5);
myservo.write(0);
randomSeed(analogRead(0));
randchoice = random(1,16);
}
void loop() {
chooseMap();
butt1 = digitalRead(but1);
butt2 = digitalRead(but2);
butt3 = digitalRead(but3);
butt4 = digitalRead(but4);
if (count >= 4){
checkPass();
}
Serial.print(arr_b[0]);
Serial.print(arr_b[1]);
Serial.print(arr_b[2]);
Serial.println(arr_b[3]);
}
boolean array_cmp(int *a, int *b, int len_a, int len_b){
int n;
// test each element to be the same. if not, return false
for (n=0;n<len_a;n++) if (a[n]!=b[n]) return false;
return true;
}
void checkPass(){
if (array_cmp(arr_a, arr_b, 4, 4) == true){
correctPass();
}
else{
wrongPass();
}
}
void correctPass(){
myservo.write(180);
delay(5000);
myservo.write(0);
memset(arr_b,0,sizeof(arr_b));
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
count=0;
randchoice = random(1,16);
chooseMap();
}
void wrongPass(){
memset(arr_b,0,sizeof(arr_b));
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
count=0;
}
//assign mapping
void chooseMap(){
if(randchoice == 1) {
buttonMap1();
}
else if (randchoice == 2) {
buttonMap2();
}
else if (randchoice == 3) {
buttonMap3();
}
else if (randchoice == 4) {
buttonMap4();
}
else if (randchoice == 5) {
buttonMap5();
}
else if (randchoice == 6) {
buttonMap6();
}
else if (randchoice == 7) {
buttonMap7();
}
else if (randchoice == 8) {
buttonMap8();
}
else if (randchoice == 9) {
buttonMap9();
}
else if (randchoice == 10) {
buttonMap10();
}
else if (randchoice == 11) {
buttonMap11();
}
else if (randchoice == 12) {
buttonMap12();
}
else if (randchoice == 13) {
buttonMap13();
}
else if (randchoice == 14) {
buttonMap14();
}
else if (randchoice == 15) {
buttonMap15();
}
else if (randchoice == 16) {
buttonMap16();
}
}
//Button Mapping Options//
void buttonMap1(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap2(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap3(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap4(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap5(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap6(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap7(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap8(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap9(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap10(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap11(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap12(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap13(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap14(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap15(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
void buttonMap16(){
if(butt1 != lbutt1) {
if(butt1 == HIGH){
digitalWrite(led3, HIGH);
arr_b[count] = 3;
count++;
}
delay(50);
}
if(butt2 != lbutt2) {
if(butt2 == HIGH){
digitalWrite(led1, HIGH);
arr_b[count] = 1;
count++;
}
delay(50);
}
if(butt3 != lbutt3) {
if(butt3 == HIGH){
digitalWrite(led2, HIGH);
arr_b[count] = 2;
count++;
}
delay(50);
}
if(butt4 != lbutt4) {
if(butt4 == HIGH){
digitalWrite(led4, HIGH);
arr_b[count] = 4;
count++;
}
delay(50);
}
lbutt1 = butt1;
lbutt2 = butt2;
lbutt3 = butt3;
lbutt4 = butt4;
}
Comments
Post a Comment