Arduino 3x3x3 Cube

From S23Wiki
Jump to: navigation, search

Arduino 3x3x3 LED Cube

<youtube>TBsPUq5EnRY</youtube>

int  p13 = 13;
int  p12 = 12;
int  p11 = 11;
int  p10 = 10;
int  p9 = 9;
int  p8 = 8;
int  p7 = 7;
int  p6 = 6;
int  p5 = 5;
int  p4 = 4; 
int  p3 = 3;
int  p2 = 2;
int  p1 = 1;
int  p0 = 0;

int sensorPin = 0;
int sensorValue = 0;
int sensorMin = 1023;  // minimum sensor value
int sensorMax = 0; 

void setup() {
  pinMode(p13, OUTPUT);
  pinMode(p12, OUTPUT);
  pinMode(p11, OUTPUT);
  pinMode(p10, OUTPUT);
  pinMode(p9, OUTPUT);
  pinMode(p8, OUTPUT);
  pinMode(p7, OUTPUT);
  pinMode(p6, OUTPUT);
  pinMode(p5, OUTPUT);
  pinMode(p4, OUTPUT);
  pinMode(p3, OUTPUT);
  pinMode(p2, OUTPUT);
  pinMode(p1, OUTPUT);
  pinMode(p0, OUTPUT);
  digitalWrite(p13,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p11,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p8,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p5,LOW);
  digitalWrite(p4,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p2,LOW);
  digitalWrite(p1,LOW);
  digitalWrite(p0,LOW);

}

void d1(){
  delay(sensorValue);
}
void aus(){
  digitalWrite(p13,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p11,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p8,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p5,LOW);
  digitalWrite(p4,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p2,LOW);
  digitalWrite(p1,LOW);
  digitalWrite(p0,LOW);
}
void a1(){ 
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW);
  digitalWrite(p5,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p8,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p11,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}

void a2(){ 
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW);
  digitalWrite(p5,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p8,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p11,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
} 

void a3() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p8,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p11,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p13,LOW); 
  sensorValue = analogRead(sensorPin);
} 
void b1(){ 
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,LOW);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void b2(){ 
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,LOW);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
} 

void b3() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,LOW);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
} 
void c1(){ 
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}

void c2(){ 
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
} 

void c3() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
} 

void L11() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
} 
void L12() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L13() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L14() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L15() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L16() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L17() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L18() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L19() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void L21() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
} 
void L22() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L23() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L24() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L25() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L26() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L27() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L28() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L29() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L31() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
} 
void L32() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L33() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L34() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L35() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L36() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L37() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L38() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void L39() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void R1() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}
void R2() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void R3() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void R4() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}
void R5() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void R6() {
  digitalWrite(p2,LOW);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void R7() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}
void R8() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void R9() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,LOW);
  digitalWrite(p4,LOW); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void Z1() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,LOW);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void Z2() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,LOW);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void Z3() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,LOW);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void Z4() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,LOW);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void Z5() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,LOW);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void Z6() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,LOW);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}
void Z7() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,LOW);
  sensorValue = analogRead(sensorPin);
}
void Z8() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p12,LOW);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}

void Z9() {
  digitalWrite(p2,HIGH);
  digitalWrite(p3,HIGH);
  digitalWrite(p4,HIGH); 
  digitalWrite(p5,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p11,LOW);
  digitalWrite(p12,HIGH);
  digitalWrite(p13,HIGH);
  sensorValue = analogRead(sensorPin);
}



void loop() {
  noInterrupts();

  sensorValue = analogRead(sensorPin); 
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 1023);
  sensorValue = constrain(sensorValue, 0, 1023);


  interrupts();


int LED1;
  LED1 =  (random (1, 19)); 
  d1();
  switch (LED1)         
  {
  case 1:
    a1();
    break;
  case 2:
    a2();
    break;
  case 3:
    a3();
    break;
  case 4:
    b1();
    break;
  case 5:
    b2();
    break;
  case 6:
    b3();
    break;
  case 7:
    c1();
    break;
  case 8:
    c2();
    break;    
  case 9:
    c3();
    break;    
case 10:
    Z1();
    break;
  case 11:
    Z2();
    break;
  case 12:
    Z3();
    break;
  case 13:
    Z4();
    break;
  case 14:
    Z5();
    break;
  case 15:
    Z6();
    break;
  case 16:
    Z7();
    break;
  case 17:
    Z8();
    break;    
  case 18:
    Z9();
    break;    
  default: 
    aus();
    break;
  }

//  int LED1;
//  LED1 =  (random (1, 10)); 
//  d1();
//  switch (LED1)         
//  {
//  case 1:
//    a1();
//    break;
//  case 2:
//    a2();
//    break;
//  case 3:
//    a3();
//    break;
//  case 4:
//    b1();
//    break;
//  case 5:
//    b2();
//    break;
//  case 6:
//    b3();
//    break;
//  case 7:
//    c1();
//    break;
//  case 78:
//    c2();
//    break;    
//  case 9:
//    c3();
//    break;    
//  default: 
//    aus();
//    break;
//  }

  //int LED1;
  //  LED1 =  (random (1, 10)); 
  //  d1();
  //  switch (LED1)         
  //  {
  //  case 1:
  //    R1();
  //    break;
  //  case 2:
  //   R2();
  //    break;
  //  case 3:
  //    R3();
  //    break;
  //  case 4:
  //    R4();
  //    break;
  //  case 5:
  //    R5();
  //    break;
  //  case 6:
  //    R6();
  //    break;
  //  case 7:
  //    R7();
  //    break;
  //  case 78:
  //    R8();
  //    break;    
  //  case 9:
  //    R9();
  //    break;    
  //  default: 
  //    aus();
  //    break;
  //  }

  //int LED1;
  //  LED1 =  (random (1, 10)); 
  //  d1();
  //  switch (LED1)         
  //  {
  //  case 1:
  //    Z1();
  //    break;
  //  case 2:
  //   Z2();
  //    break;
  //  case 3:
  //    Z3();
  //    break;
  //  case 4:
  //    Z4();
  //    break;
  //  case 5:
  //    Z5();
  //    break;
  //  case 6:
  //    Z6();
  //    break;
  //  case 7:
  //    Z7();
  //    break;
  //  case 78:
  //    Z8();
  //    break;    
  //  case 9:
  //    Z9();
  //    break;    
  //  default: 
  //    aus();
  //    break;
  //  }

  //Z1();
  //d1();
  //Z2();
  //d1();
  //Z3();
  //d1();
  //Z4();
  //d1();
  //Z5();
  //d1();
  //Z6();
  //d1();
  //Z7();
  //d1();
  //Z8();
  //d1();
  //Z9();
  //d1();

  //R1();
  //d1();
  //R2();
  //d1();
  //R3();
  //d1();
  //R4();
  //d1();
  //R5();
  //d1();
  //R6();
  //d1();
  //R7();
  //d1();
  //R8();
  //d1();
  //R9();
  //d1();

  //R1();
  //d1();
  //R2();
  //d1();
  //R3();
  //d1();
  //R6();
  //d1();
  //R9();
  //d1();
  //R8();
  //d1();
  //R7();
  //d1();
  //R4();
  //d1();

  //Z1();
  //d1();
  //Z2();
  //d1();
  //Z3();
  //d1();
  //Z6();
  //d1();
  //Z9();
  //d1();
  //Z8();
  //d1();
  //Z7();
  //d1();
  //Z4();
  //d1();

  //a1();
  //d1();
  //a2();
  //d1();
  //a3();
  //d1();
  //b1();
  //d1();
  //b2();
  //d1();
  //b3();
  //d1();  
  //c1();
  //d1();
  //c2();
  //d1();
  //c3();
  //d1();

  //L11();
  //d1();
  //L12();
  //d1();
  //L13();
  //d1();
  //L16();
  //d1();
  //L15();
  //d1();
  //L14();
  //d1();
  //L17();
  //d1();
  //L18();
  //d1();
  //L19();
  //d1();
  //L29();
  //d1();
  //L28();
  //d1();
  //L27();
  //d1();
  //L24();
  //d1();
  //L25();
  //d1();
  //L26();
  //d1();
  //L23();
  //d1();
  //L22();
  //d1();
  //L21();
  //d1();
  //L31();
  //d1();
  //L32();
  //d1();
  //L33();
  //d1();
  //L36();
  //d1();
  //L35();
  //d1();
  //L34();
  //d1();
  //L37();
  //d1();
  //L38();
  //d1();
  //L39();
  //d1();



  //L39();
  //d1();
  //L38();
  //d1();
  //L37();
  //d1();
  //L34();
  //d1();
  //L35();
  //d1();
  //L36();
  //d1();
  //L33();
  //d1();
  //L32();
  //d1();
  //L31();
  //d1();
  //L21();
  //d1();
  //L22();
  //d1();
  //L23();
  //d1();
  //L26();
  //d1();
  //L25();
  //d1();
  //L24();
  //d1();
  //L27();
  //d1();
  //L28();
  //d1();
  //L29();
  //d1();
  //L19();
  //d1();
  //L18();
  //d1();
  //L17();
  //d1();
  //L14();
  //d1();
  //L15();
  //d1();
  //L16();
  //d1();
  //L13();
  //d1();
  //L12();
  //d1();
  //L11();
  //d1();

  //L11();
  //d1();
  //L12();
  //d1();
  //L13();
  //d1();
  //L14();
  //d1();
  //L15();
  //d1();
  //L16();
  //d1();
  //L17();
  //d1();
  //L18();
  //d1();
  //L19();
  //d1();
  //L21();
  //d1();
  //L22();
  //d1();
  //L23();
  //d1();
  //L24();
  //d1();
  //L25();
  //d1();
  //L26();
  //d1();
  //L27();
  //d1();
  //L28();
  //d1();
  //L29();
  //d1();
  //L31();
  //d1();
  //L32();
  //d1();
  //L33();
  //d1();
  //L34();
  //d1();
  //L35();
  //d1();
  //L36();
  //d1();
  //L37();
  //d1();
  //L38();
  //d1();
  //L39();
  //d1();
}