bool hasRun=false;
bool hasRun2=false;
bool hasRun3=false;
bool hasRun4=false;
bool hasRun5=false;
bool hasRun6=false;
bool hasRun7=false;
void buttonCheck()
{
Serial.println (analogRead(A0));
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==598)
{
if (analogRead(A4)==0&&analogRead(A3)>0&&analogRead(A5)>0)
{
Serial.println ("a");
smallButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (5, LOW);
massButtonCheck();
massButtonCheck();
digitalWrite (6, HIGH);
digitalWrite (7, LOW);
while (hasRun==false);
{
Serial.println ("b");
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (2, HIGH);
digitalWrite (5, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
hasRun=true;
}
}
if (analogRead(A4)==0&&analogRead(A2)==408&&analogRead(A5)>0&&analogRead(A0)==0)
{
Serial.println(analogRead(A2));
if (hasRun2==false)
{
Serial.println ("c");
smallButtonCheck();
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (2, LOW);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (5, LOW);
massButtonCheck();
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (5, HIGH);
digitalWrite(6, LOW);
hasRun2=true;
}
else if (hasRun2==true&&analogRead(A5)>0);
{
Serial.println ("d");
smallButtonCheck();
allOff();
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (2, LOW);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (3, LOW);
digitalWrite (5, LOW);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
hasRun2=false;
}
}
if (analogRead(A4)==0&&analogRead(A0)==408&&analogRead(A1)==0&&analogRead(A5)>0)
{
Serial.println ("e");
if (hasRun3==false)
{
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
massButtonCheck();
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
hasRun3=true;
}
else if (hasRun3==true)
{
Serial.println ("f");
smallButtonCheck();
allOff();
cycleSix();
cycleOne();
cycleTwo();
cycleThree();
cycleFour();
cycleFive();
hasRun3=false;
}
}
if (analogRead(A5)==399)
{
if (analogRead(A3)>0&&analogRead(A4)==0&&analogRead(A5)>0)
{
if (hasRun5==false)
{
Serial.println ("g");
smallButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (5, LOW);
massButtonCheck();
digitalWrite (6, HIGH);
digitalWrite (7, LOW);
hasRun5=true;
}
if (hasRun5==true)
{
Serial.println ("h");
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (2, HIGH);
digitalWrite (5, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
hasRun5=true;
}
}
if (analogRead(A4)==0&&analogRead(A2)==408&&analogRead(A5)>0&&analogRead(A0)==0)
{
if (hasRun6==false)
{
Serial.println ("i");
smallButtonCheck();
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (2, LOW);
massButtonCheck();
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (5, LOW);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (5, HIGH);
digitalWrite(6, LOW);
hasRun6=true;
}
if (hasRun6==true)
{Serial.println ("j");
smallButtonCheck();
allOff();
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (2, LOW);
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite (7, HIGH);
digitalWrite (3, LOW);
digitalWrite (5, LOW);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
hasRun6=true;
}
}
if (analogRead(A0)>0&&analogRead(A1)==0&&analogRead(A5)>0)
{
if (hasRun7==false)
{
Serial.println ("k");
smallButtonCheck();
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
massButtonCheck();
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
smallButtonCheck();
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
massButtonCheck();
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
hasRun7=true;
}
if (hasRun7==true)
{
Serial.println ("l");
smallButtonCheck();
allOff();
cycleSix();
cycleOne();
cycleTwo();
cycleThree();
cycleFour();
cycleFive();
hasRun3=true;
}
}
}
}
}
void defaultPattern()
{
cycleOne();
cycleTwo();
cycleThree();
cycleFour();
cycleFive();
cycleSix();
}
void smallButtonCheck()
{
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
}
void massButtonCheck()
{
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
delay(100);
buttonCheck();
}
void maintenance()
{
if (analogRead(A5)==201)
{
Serial.println (analogRead(A5));
digitalWrite (2, HIGH);
digitalWrite (5, HIGH);
digitalWrite (4, LOW);
digitalWrite (3, LOW);
digitalWrite (6, LOW);
digitalWrite (7, LOW);
delay(1500);
if (analogRead(A5)==201)
{
digitalWrite (2, LOW);
digitalWrite (5, LOW);
digitalWrite (4, HIGH);
digitalWrite (7, HIGH);
delay(1500);
}
else if (analogRead(A5)!=201)
{
defaultPattern();
}
}
}
void cycleOne()
{
if (analogRead(A5)==201)
{
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (5, LOW);
digitalWrite (6, LOW);
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
digitalWrite (7, HIGH);
digitalWrite (4, LOW);
massButtonCheck();
}
}
void cycleTwo()
{
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
smallButtonCheck();
}
}
void cycleThree()
{
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
digitalWrite (4, LOW);
digitalWrite (2, HIGH);
digitalWrite (3, LOW);
digitalWrite (7, LOW);
smallButtonCheck();
}
}
void cycleFour()
{
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
massButtonCheck();
}
}
void cycleFive()
{
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
smallButtonCheck();
}
}
void cycleSix()
{
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
smallButtonCheck();
}
}
void allOff()
{
for (int x=2; x<=13; x++)
{
digitalWrite (x, LOW);
}
}
void setup()
{
for (int i=2; i<=13; i++)
{
pinMode (i, OUTPUT);
}
Serial.begin (9600);
}
void loop()
{
Serial.println (analogRead(A5));
if (analogRead(A5)==201)
{
allOff();
maintenance();
}
else if (analogRead(A5)==0)
{
defaultPattern();
}
}