Arduino 5x5x3

From S23Wiki
Jump to: navigation, search

Arduino 5x5x3

Das Ansprechen der Ports direkt ohne die Pinwritebefehle, verbraucht massiv weniger Platz auf dem Chip!

        PORTB = B00111111;  
        PORTD = B11100000;

anstatt

  digitalWrite(p13,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p5,HIGH);
  digitalWrite(p4,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p2,LOW);
  digitalWrite(p1,LOW);
  digitalWrite(p0,LOW);

siehe auch


Bauphase:

code:

//pin belegung
//13 12 11 gruen
//10 9 8 lila
//7 6 5  blau
//4 3 2 1 0 black

int anode1[] = {5, 6, 7, 8, 9, 10, 11, 12, 13};
int cathode1[] = {0, 1, 2, 3, 4};
int anode[] = {0, 1, 2, 3, 4};
int cathode[] = {5, 6, 7, 8, 9, 10, 11, 12, 13};

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; 
int sensorPin2 = 1;
int sensorValue2 = 0;
int sensorMin2 = 0;  // minimum sensor value
int sensorMax2 = 1023; 
int sensorPin3 = 2;
int sensorValue3 = 0;
int sensorMin3 = 0;  // minimum sensor value
int sensorMax3 = 1023; 
int sensorPin4 = 3;
int sensorValue4 = 0;
int sensorMin4 = 0;  // minimum sensor value
int sensorMax4 = 1023; 

int LED1;
int r1;
long heartBeatArray[] = {  
  50, 100, 15, 1200};
int hbeatIndex = 1;   // this initialization is important or it starts on the "wrong foot"
long prevMillis;

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,HIGH);
  digitalWrite(p12,HIGH);
  digitalWrite(p11,HIGH);
  digitalWrite(p10,HIGH);
  digitalWrite(p9,HIGH);
  digitalWrite(p8,HIGH);
  digitalWrite(p7,HIGH);
  digitalWrite(p6,HIGH);
  digitalWrite(p5,LOW);
  digitalWrite(p4,LOW);
  digitalWrite(p3,LOW);
  digitalWrite(p2,LOW);
  digitalWrite(p1,LOW);
  digitalWrite(p0,LOW);

}

void loop() {
  noInterrupts();

  sensorValue = analogRead(sensorPin); 
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 1023);
  sensorValue = constrain(sensorValue, 0, 1023);
  sensorValue2 = analogRead(sensorPin2); 
  sensorValue2 = map(sensorValue2, sensorMin2, sensorMax2, 0, 45);
  sensorValue2 = constrain(sensorValue2, 0, 45);
  sensorValue3 = analogRead(sensorPin3); 
  sensorValue3 = map(sensorValue3, sensorMin3, sensorMax3, 0, 26);
  sensorValue3 = constrain(sensorValue3, 0, 26);
  sensorValue4 = analogRead(sensorPin4); 
  sensorValue4 = map(sensorValue4, sensorMin4, sensorMax4, 0, 27);
  sensorValue4 = constrain(sensorValue4, 0, 27);


  interrupts();
  int PW;
  PW = (sensorValue4);
  switch (PW) 
  {
case 0:
aus();

break;
  case 1:
    //// Lauflicht 1 6 11 3 7 12 usw
 lauflicht1();
    ////
    break;
  case 2:
    //// Lauflicht 2
    lauflicht2();
    ////
    break;  
  case 3:
    ////Saulen 1-15
    saeulen1();
    ////
    break;
  case 4:
    //// Lines 1-6
    lines1();
    ////
    break;
  case 5:
    //// reihen 1-15
    reihen1();
    ////
    break;
      case 6:
    //// s.o.
    saeulen1();
    lines1();
    reihen1();
    ////
    break;
  case 7:
    ////flaeche1 9x9
    flaeche1();
    ////
    break;
  case 8:
    ////flache2 3x5
    flaeche2();
    ////
    break;
  case 9:
    ////flaeche3 3x15 2
    flaeche3();
    ////
    break;
  case 10:
    ////s.o.
    flaeche1();
    flaeche2();
    flaeche3();
    ////
    break;
  case 11:
    ////zufalls licht 1
    random1();
    ////
    break;
  case 12:
    ////
    heartBeat(1.0);   // try changing the parameter
    ////
    break;
  case 13:
  /// random reihe
  reihen1random();
  ///
  break;
 case 14:
  /// random line
  lines1random();
  ///
  break;
 case 15:
  /// random reihe
  saeulen1random();
  ///
  break;
 case 16:
  /// random reihe
  LED1 = (random (0, 3));
  switch (LED1){
    case 0:
    reihen1random();
    break;
        case 1:
    lines1random();
    break;
        case 2:
    saeulen1random();
    break;
    

  }
   ///
  break;
 
 case 17:
  /// random reihe
  flaeche1random();
  ///
  break;
 case 18:
  /// random reihe
  flaeche2random();
  ///
  break;
 case 19:
  /// random reihe
  flaeche3random();
  ///
  break;
 case 20:
  /// random reihe
 LED1 = (random (0, 3));
  switch (LED1){
    case 0:
    flaeche1random();
    break;
        case 1:
    flaeche2random();
    break;
        case 2:
    flaeche3random();
    break;
    

  }
  ///
  break;

     case 21:
     
     
 LED1 = (random (0, 8));
switch (LED1){
case 0:
  flaeche1random();
  break;
case 1:
  flaeche2random();
  break;
case 3:
  flaeche3random();
  break;
case 4:
  reihen1random();
  break;
case 5:
  lines1random();
  break;
case 6:
  saeulen1random();
  break;
case 7:
  random1();
  break;
}

   break; 

     case 22:
  an();
   break;  


  case 23:
   oneByOne();
   break;
   case 24:
   oneByOne1();
   break; 
     case 25:
    oneByOne2();
   break; 
     case 26:
 oneByOne3();
   break;   

     case 27:
 oneByOne4();
   break; 



  default: 
    aus();
    break;
  }  





















}
/////////////////////////////////
/////////////////////////////////



void flaeche3random(){
  LED1 = (random (0,3));
 switch (LED1){
   case 0:
  W1();
  d1();
   break;

   case 1:
  W2();
  d1();
   break;
   
   case 2:
  W3();
  d1();
   break;   
}}

void flaeche3(){
  W1();
  d1();
  W2();
  d1(); 
  W3();
  d1(); 
}
void flaeche2(){
  E1();
  d1();
  E2();
  d1(); 
  E3();
  d1(); 
}
void flaeche1(){
  Q1();
  d1();
  Q2();
  d1(); 
  Q3();
  d1(); 
  Q4();
  d1();
  Q5();
  d1(); 
}

void flaeche2random(){
  LED1 = (random (0,3));
 switch (LED1){
   case 0:
  E1();
  d1();
   break;

   case 1:
  E2();
  d1();
   break;
   
   case 2:
  E3();
  d1();
   break;   
}}

void flaeche1random(){
  LED1 = (random (0,5));
 switch (LED1){
   case 0:
  Q1();
  d1();
   break;

   case 1:
  Q2();
  d1();
   break;
   
   case 2:
  Q3();
  d1();
   break;   

   case 3:
  Q4();
  d1();
   break;
    case 4:
  Q5();
  d1();
   break; 
 
}
}
void reihen1(){
  aR1();
  d1();
  aR2();
  d1(); 
  aR3();
  d1(); 
  aR4();
  d1(); 
  aR5();
  d1(); 
  bR1();
  d1();
  bR2();
  d1(); 
  bR3();
  d1(); 
  bR4();
  d1(); 
  bR5();
  d1();   
  cR1();
  d1();
  cR2();
  d1(); 
  cR3();
  d1(); 
  cR4();
  d1(); 
  cR5();
  d1(); 
}
void reihen1random(){
 LED1 = (random (0,16));
 switch (LED1){
   case 0:
  aR1();
  d1();
  break;
  case 1:
  aR2();
  d1(); 
  break;
  case 2:
  aR3();
  d1(); 
  break;
  case 4:
  aR4();
  d1(); 
  break;
  case 5:
  aR5();
  d1(); 
  break;
  case 6:
  bR1();
  d1();
  break;
  case 7:
  bR2();
  d1(); 
  break;
  case 8:
  bR3();
  d1(); 
  break;
  case 9:
  bR4();
  d1(); 
  break;
  case 10:
  bR5();
  d1();  
 break;
  case 11: 
  cR1();
  d1();
  break;
  case 12:
  cR2();
  d1(); 
  break;
  case 13:
  cR3();
  d1(); 
  break;
  case 14:
  cR4();
  d1(); 
  break;
  case 15:
  cR5();
  d1(); 
  break;
 }
}


void lines1random(){
 LED1 = (random (0,9));
 switch (LED1){
   case 0:
  aL1();
  d1();
  break;
  case 1:
  aL2();
  d1(); 
  break;
  case 2:
  aL3();
  d1(); 
  break;
  case 3:
  bL1();
  d1(); 
  break;
  case 4:
  bL2();
  d1(); 
  break;
  case 5:
  bL3();
  d1();
  break;
  case 6:
  cL1();
  d1(); 
  break;
  case 7:
  cL2();
  d1(); 
  break;
  case 8:
  cL3();
  d1(); 
  break;
 }}
void lines1(){
  aL1();
  d1();
  aL2();
  d1(); 
  aL3();
  d1(); 
  bL1();
  d1();
  bL2();
  d1(); 
  bL3();
  d1(); 
  cL1();
  d1();
  cL2();
  d1(); 
  cL3();
  d1(); 
}

void saeulen1random(){
 LED1 = (random (0,16));
 switch (LED1){
   case 0:
  S1();
  d1();
  break;
  case 1:
  S2();
  d1(); 
  break;
  case 2:
  S3();
  d1(); 
  break;
  case 4:
  S4();
  d1(); 
  break;
  case 5:
  S5();
  d1(); 
  break;
  case 6:
  S6();
  d1();
  break;
  case 7:
  S7();
  d1(); 
  break;
  case 8:
  S8();
  d1(); 
  break;
  case 9:
  S9();
  d1(); 
  break;
  case 10:
  S10();
  d1();  
 break;
  case 11: 
  S11();
  d1();
  break;
  case 12:
  S12();
  d1(); 
  break;
  case 13:
  S13();
  d1(); 
  break;
  case 14:
  S14();
  d1(); 
  break;
  case 15:
  S15();
  d1(); 
  break;
 }
}
void saeulen1(){
  S1();
  d1();
  S2();
  d1(); 
  S3();
  d1(); 
  S4();
  d1();
  S5();
  d1(); 
  S6();
  d1();
  S7();
  d1(); 
  S8();
  d1(); 
  S9();
  d1();
  S10();
  d1(); 
  S11();
  d1(); 
  S12();
  d1();
  S13();
  d1(); 
  S14();
  d1(); 
  S15();
  d1(); 
}


void lauflicht1(){
  aD1();
  d1();
  aD6();
  d1(); 
  aD11();
  d1(); 
  aD2();
  d1();
  aD7();
  d1();
  aD12();
  d1();
  aD3();
  d1(); 
  aD8();
  d1(); 
  aD13();
  d1();
  aD4();
  d1();
  aD9();
  d1();
  aD14();
  d1(); 
  aD5();
  d1(); 
  aD10();
  d1();
  aD15();
  d1();
  bD1();
  d1();
  bD6();
  d1(); 
  bD11();
  d1(); 
  bD2();
  d1();
  bD7();
  d1();
  bD12();
  d1();
  bD3();
  d1(); 
  bD8();
  d1(); 
  bD13();
  d1();
  bD4();
  d1();
  bD9();
  d1();
  bD14();
  d1(); 
  bD5();
  d1(); 
  bD10();
  d1();
  bD15();
  d1();
  cD1();
  d1();
  cD6();
  d1(); 
  cD11();
  d1(); 
  cD2();
  d1();
  cD7();
  d1();
  cD12();
  d1();
  cD3();
  d1(); 
  cD8();
  d1(); 
  cD13();
  d1();
  cD4();
  d1();
  cD9();
  d1();
  cD14();
  d1(); 
  cD5();
  d1(); 
  cD10();
  d1();
  cD15();
  d1();
}

void lauflicht2(){
aD1();
d1();
aD2();
d1();
aD3();
d1();
aD4();
d1();
aD5();
d1();
aD10();
d1();
aD9();
d1();
aD8();
d1();
aD7();
d1();
aD6();
d1();
aD11();
d1();
aD12();
d1();
aD13();
d1();
aD14();
d1();
aD15();
d1();
bD15();
d1();
bD14();
d1();
bD13();
d1();
bD12();
d1();
bD11();
d1();
bD6();
d1();
bD7();
d1();
bD8();
d1();
bD9();
d1();
bD10();
d1();
bD5();
d1();
bD4();
d1();
bD3();
d1();
bD2();
d1();
bD1();
d1();
cD1();
d1();
cD2();
d1();
cD3();
d1();
cD4();
d1();
cD5();
d1();
cD10();
d1();
cD9();
d1();
cD8();
d1();
cD7();
d1();
cD6();
d1();
cD11();
d1();
cD12();
d1();
cD13();
d1();
cD14();
d1();
cD15();
d1();

cD15();
d1();
cD10();
d1();
cD5();
d1();
cD4();
d1();
cD9();
d1();
cD14();
d1();
cD13();
d1();
cD8();
d1();
cD3();
d1();
cD2();
d1();
cD7();
d1();
cD12();
d1();
cD11();
d1();
cD6();
d1();
cD1();
d1();


bD1();
d1();
bD6();
d1();
bD11();
d1();
bD12();
d1();
bD7();
d1();
bD2();
d1();
bD3();
d1();
bD8();
d1();
bD13();
d1();
bD14();
d1();
bD9();
d1();
bD4();
d1();
bD5();
d1();
bD10();
d1();
bD15();
d1();



aD15();
d1();
aD10();
d1();
aD5();
d1();
aD4();
d1();
aD9();
d1();
aD14();
d1();
aD13();
d1();
aD8();
d1();
aD3();
d1();
aD2();
d1();
aD7();
d1();
aD12();
d1();
aD11();
d1();
aD6();
d1();
aD1();
d1();
}

void d1(){
  delay(sensorValue);
  sensorValue = analogRead(sensorPin);
  sensorValue2 = analogRead(sensorPin2); 
  sensorValue3 = analogRead(sensorPin3);
  sensorValue4 = analogRead(sensorPin4); 
}
void aus(){
        PORTB = B00111111;  
        PORTD = B11100000;
  sensorValue = analogRead(sensorPin);
}
void an(){
        PORTB = B00000000;  
        PORTD = B00011111;
  sensorValue = analogRead(sensorPin);
}
void aR1(){ 
        PORTB = B00111111;  
        PORTD = B00010000;
  sensorValue = analogRead(sensorPin);
} 
void aR2(){ 
        PORTB = B00111111;  
        PORTD = B00001000;
  sensorValue = analogRead(sensorPin);
} 
void aR3(){ 
        PORTB = B00111111;  
        PORTD = B00000100;
  sensorValue = analogRead(sensorPin);
} 
void aR4(){ 
        PORTB = B00111111;  
        PORTD = B00000010;
  sensorValue = analogRead(sensorPin);
}
void aR5(){ 
        PORTB = B00111111;  
        PORTD = B00000001;
  sensorValue = analogRead(sensorPin);
}

void bR1(){ 
        PORTB = B00111000;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
} 
void bR2(){ 
        PORTB = B00111000;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
} 
void bR3(){ 
        PORTB = B00111000;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void bR4(){ 
        PORTB = B00111000;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
}
void bR5(){ 
        PORTB = B00111000;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
}

void cR1(){ 
        PORTB = B00000111;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
} 
void cR2(){ 
        PORTB = B00000111;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
} 
void cR3(){ 
        PORTB = B00000111;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void cR4(){ 
        PORTB = B00000111;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
}
void cR5(){ 
        PORTB = B00000111;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
}


void aL1(){ 
        PORTB = B00111111;  
        PORTD = B11011111;
  sensorValue = analogRead(sensorPin);
}
void aL2(){ 
        PORTB = B00111111;  
        PORTD = B10111111;
  sensorValue = analogRead(sensorPin);
}  
void aL3(){ 
        PORTB = B00111111;  
        PORTD = B01111111;
  sensorValue = analogRead(sensorPin);
} 

void bL1(){ 
        PORTB = B00111110;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}
void bL2(){ 
        PORTB = B00111101;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}  
void bL3(){ 
        PORTB = B00111011;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
} 

void cL1(){ 
        PORTB = B00110111;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}
void cL2(){ 
        PORTB = B00101111;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}  
void cL3(){ 
        PORTB = B00011111;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
} 

void aD1(){ 
        PORTB = B00111111;  
        PORTD = B11010000;
  sensorValue = analogRead(sensorPin);
}
void aD2(){ 
        PORTB = B00111111;  
        PORTD = B11001000;
  sensorValue = analogRead(sensorPin);
}  
void aD3(){ 
        PORTB = B00111111;  
        PORTD = B11000100;
  sensorValue = analogRead(sensorPin);
} 
void aD4(){ 
        PORTB = B00111111;  
        PORTD = B11000010;
  sensorValue = analogRead(sensorPin);
} 
void aD5(){ 
        PORTB = B00111111;  
        PORTD = B11000001;
  sensorValue = analogRead(sensorPin);
} 
void aD6(){ 
        PORTB = B00111111;  
        PORTD = B10110000;
  sensorValue = analogRead(sensorPin);
}
void aD7(){ 
        PORTB = B00111111;  
        PORTD = B10101000;
  sensorValue = analogRead(sensorPin);
}  
void aD8(){ 
        PORTB = B00111111;  
        PORTD = B10100100;
  sensorValue = analogRead(sensorPin);
} 
void aD9(){ 
        PORTB = B00111111;  
        PORTD = B10100010;
  sensorValue = analogRead(sensorPin);
} 
void aD10(){ 
        PORTB = B00111111;  
        PORTD = B10100001;
  sensorValue = analogRead(sensorPin);
} 
void aD11(){ 
        PORTB = B00111111;  
        PORTD = B01110000;
  sensorValue = analogRead(sensorPin);
}
void aD12(){ 
        PORTB = B00111111;  
        PORTD = B01101000;
  sensorValue = analogRead(sensorPin);
}  
void aD13(){ 
        PORTB = B00111111;  
        PORTD = B01100100;
  sensorValue = analogRead(sensorPin);
} 
void aD14(){ 
        PORTB = B00111111;  
        PORTD = B01100010;
  sensorValue = analogRead(sensorPin);
} 
void aD15(){ 
        PORTB = B00111111;  
        PORTD = B01100001;
  sensorValue = analogRead(sensorPin);
}
void bD1(){ 
        PORTB = B00111110;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void bD2(){ 
        PORTB = B00111110;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void bD3(){ 
        PORTB = B00111110;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void bD4(){ 
        PORTB = B00111110;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void bD5(){ 
        PORTB = B00111110;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
} 
void bD6(){ 
        PORTB = B00111101;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void bD7(){ 
        PORTB = B00111101;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void bD8(){ 
        PORTB = B00111101;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void bD9(){ 
        PORTB = B00111101;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void bD10(){ 
        PORTB = B00111101;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
} 
void bD11(){ 
        PORTB = B00111011;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void bD12(){ 
        PORTB = B00111011;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void bD13(){ 
        PORTB = B00111011;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void bD14(){ 
        PORTB = B00111011;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void bD15(){ 
        PORTB = B00111011;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
}

void cD1(){ 
        PORTB = B00110111;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void cD2(){ 
        PORTB = B00110111;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void cD3(){ 
        PORTB = B00110111;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void cD4(){ 
        PORTB = B00110111;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void cD5(){ 
        PORTB = B00110111;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
} 
void cD6(){ 
        PORTB = B00101111;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void cD7(){ 
        PORTB = B00101111;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void cD8(){ 
        PORTB = B00101111;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void cD9(){ 
        PORTB = B00101111;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void cD10(){ 
        PORTB = B00101111;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
} 
void cD11(){ 
        PORTB = B00011111;  
        PORTD = B11110000;
  sensorValue = analogRead(sensorPin);
}
void cD12(){ 
        PORTB = B00011111;  
        PORTD = B11101000;
  sensorValue = analogRead(sensorPin);
}  
void cD13(){ 
        PORTB = B00011111;  
        PORTD = B11100100;
  sensorValue = analogRead(sensorPin);
} 
void cD14(){ 
        PORTB = B00011111;  
        PORTD = B11100010;
  sensorValue = analogRead(sensorPin);
} 
void cD15(){ 
        PORTB = B00011111;  
        PORTD = B11100001;
  sensorValue = analogRead(sensorPin);
}

void S1(){ 
        PORTB = B00110110;  
        PORTD = B11010000;
  sensorValue = analogRead(sensorPin);
}
void S2(){ 
        PORTB = B00110110;  
        PORTD = B11001000;
  sensorValue = analogRead(sensorPin);
}
void S3(){ 
        PORTB = B00110110;  
        PORTD = B11000100;
  sensorValue = analogRead(sensorPin);
}
void S4(){ 
        PORTB = B00110110;  
        PORTD = B11000010;
  sensorValue = analogRead(sensorPin);
}
void S5(){ 
        PORTB = B00110110;  
        PORTD = B11000001;
  sensorValue = analogRead(sensorPin);
}
void S6(){ 
        PORTB = B00101101;  
        PORTD = B10110000;
  sensorValue = analogRead(sensorPin);
}
void S7(){ 
        PORTB = B00101101;  
        PORTD = B10101000;
  sensorValue = analogRead(sensorPin);
}
void S8(){ 
        PORTB = B00101101;  
        PORTD = B10100100;
  sensorValue = analogRead(sensorPin);
}
void S9(){ 
        PORTB = B00101101;  
        PORTD = B10100010;
  sensorValue = analogRead(sensorPin);
}
void S10(){ 
        PORTB = B00101101;  
        PORTD = B10100001;
  sensorValue = analogRead(sensorPin);
}
void S11(){ 
        PORTB = B00011011;  
        PORTD = B01110000;
  sensorValue = analogRead(sensorPin);
}
void S12(){ 
        PORTB = B00011011;  
        PORTD = B01101000;
  sensorValue = analogRead(sensorPin);
}
void S13(){ 
        PORTB = B00011011;  
        PORTD = B01100100;
  sensorValue = analogRead(sensorPin);
}
void S14(){ 
        PORTB = B00011011;  
        PORTD = B01100010;
  sensorValue = analogRead(sensorPin);
}
void S15(){ 
        PORTB = B00011011;  
        PORTD = B01100001;
  sensorValue = analogRead(sensorPin);
}

void Q1(){ 
        PORTB = B00000000;  
        PORTD = B00010000;
  sensorValue = analogRead(sensorPin);
} 
void Q2(){ 
        PORTB = B00000000;  
        PORTD = B00001000;
  sensorValue = analogRead(sensorPin);
} 
void Q3(){ 
        PORTB = B00000000;  
        PORTD = B00000100;
  sensorValue = analogRead(sensorPin);
} 
void Q4(){ 
        PORTB = B00000000;  
        PORTD = B00000010;
  sensorValue = analogRead(sensorPin);
}
void Q5(){ 
        PORTB = B00000000;  
        PORTD = B00000001;
  sensorValue = analogRead(sensorPin);
}

void E1(){ 
        PORTB = B00110110;  
        PORTD = B11011111;
  sensorValue = analogRead(sensorPin);
}
void E2(){ 
        PORTB = B00101101;  
        PORTD = B10111111;
  sensorValue = analogRead(sensorPin);
}
void E3(){ 
        PORTB = B00011011;  
        PORTD = B01111111;
  sensorValue = analogRead(sensorPin);
}

void W1(){ 
        PORTB = B00111111;  
        PORTD = B00011111;
  sensorValue = analogRead(sensorPin);
}
void W2(){ 
        PORTB = B00111000;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}
void W3(){ 
        PORTB = B00000111;  
        PORTD = B11111111;
  sensorValue = analogRead(sensorPin);
}
void heartBeat(float tempo){

  if ((millis() - prevMillis) > (long)(heartBeatArray[hbeatIndex] * tempo)){
    hbeatIndex++;
    if (hbeatIndex > 3) hbeatIndex = 0;

    if ((hbeatIndex % 2) == 0){ 
      an();
      delay((int)heartBeatArray[hbeatIndex]) ;   
      aus(); 
    }
    hbeatIndex++;
    // Serial.println(hbeatIndex);
    prevMillis = millis();

  }
}
void random1(){
    sensorValue2 = analogRead(sensorPin2); 
  sensorValue2 = map(sensorValue2, sensorMin2, sensorMax2, 0, 45);
  sensorValue2 = constrain(sensorValue2, 0, 45);
  sensorValue3 = analogRead(sensorPin3); 
  sensorValue3 = map(sensorValue3, sensorMin3, sensorMax3, 0, 45);
   sensorValue3 = constrain(sensorValue3, 0, 45);
  
  r1 = (random (sensorValue3, sensorValue2));
  switch (r1){
  case 0:
    aD1();
    d1();
    break;
  case 1:
    aD2();
    d1(); 
    break;
  case 2:
    aD3();
    d1(); 
    break;
  case 3:
    aD4();
    d1();
    break;
  case 4:
    aD5();
    d1();
    break;
  case 5:
    aD6();
    d1();
    break;
  case 6:
    aD7();
    d1();
    break;
  case 7:
    aD8();
    d1();
    break;
  case 8:
    aD9();
    d1();
    break;  
  case 9:
    aD10();
    d1();
    break;  
  case 10:
    aD11();
    d1();
    break;  
  case 11:
    aD12();
    d1();
    break;  
  case 12:
    aD13();
    d1();
    break;  
  case 13:
    aD14();
    d1();
    break;  
  case 14:
    aD15();
    d1();
    break;  
  case 15:
    bD1();
    d1();
    break;
  case 16:
    bD2();
    d1(); 
    break;
  case 17:
    bD3();
    d1(); 
    break;
  case 18:
    bD4();
    d1();
    break;
  case 19:
    bD5();
    d1();
    break;
  case 20:
    bD6();
    d1();
    break;
  case 21:
    bD7();
    d1();
    break;
  case 22:
    bD8();
    d1();
    break;
  case 23:
    bD9();
    d1();
    break;  
  case 24:
    bD10();
    d1();
    break;  
  case 25:
    bD11();
    d1();
    break;  
  case 26:
    bD12();
    d1();
    break;  
  case 27:
    bD13();
    d1();
    break;  
  case 28:
    bD14();
    d1();
    break;  
  case 29:
    bD15();
    d1();
    break;   
  case 30:
    cD1();
    d1();
    break;
  case 31:
    cD2();
    d1(); 
    break;
  case 32:
    cD3();
    d1(); 
    break;
  case 33:
    cD4();
    d1();
    break;
  case 34:
    cD5();
    d1();
    break;
  case 35:
    cD6();
    d1();
    break;
  case 36:
    cD7();
    d1();
    break;
  case 37:
    cD8();
    d1();
    break;
  case 38:
    cD9();
    d1();
    break;  
  case 39:
    cD10();
    d1();
    break;  
  case 40:
    cD11();
    d1();
    break;  
  case 41:
    cD12();
    d1();
    break;  
  case 42:
    cD13();
    d1();
    break;  
  case 43:
    cD14();
    d1();
    break;  
  case 44:
    cD15();
    d1();
    break; 
  default: 
    aus();
    break;
  }
}
void oneByOne() {

  for(int c = 0; c < 9; c++) {          // Alle Ebenen nacheinander

    for(int a = 0; a < 5; a++) {        // Alle LEDs einer Ebene nacheinander

      digitalWrite(anode[a], HIGH);     // LED anschalten

      digitalWrite(cathode[c], LOW);
sensorValue = analogRead(sensorPin); 
      delay(sensorValue);

      digitalWrite(anode[a], LOW);      // LED ausschalten

      digitalWrite(cathode[c], HIGH);

    }

  }

}

void oneByOne1() {

  for(int c = 0; c < 9; c++) {          // Alle Ebenen nacheinander

    for(int a = 0; a < 5; a++) {        // Alle LEDs einer Ebene nacheinander

      digitalWrite(anode[a], LOW);     // LED anschalten

      digitalWrite(cathode[c], HIGH);
sensorValue = analogRead(sensorPin); 
      delay(sensorValue);

      digitalWrite(anode[a], HIGH);      // LED ausschalten

      digitalWrite(cathode[c], LOW);

    }

  }

}

void oneByOne2() {

  for(int c = 0; c < 5; c++) {          // Alle Ebenen nacheinander

    for(int a = 0; a < 9; a++) {        // Alle LEDs einer Ebene nacheinander

      digitalWrite(anode1[a], LOW);     // LED anschalten

      digitalWrite(cathode1[c], HIGH);
sensorValue = analogRead(sensorPin); 
      delay(sensorValue);

      digitalWrite(anode1[a], HIGH);      // LED ausschalten

      digitalWrite(cathode1[c], LOW);

    }

  }

}
void oneByOne3() {

  for(int c = 0; c < 5; c++) {          // Alle Ebenen nacheinander

    for(int a = 0; a < 9; a++) {        // Alle LEDs einer Ebene nacheinander

      digitalWrite(anode1[a], HIGH);     // LED anschalten

      digitalWrite(cathode1[c], LOW);
sensorValue = analogRead(sensorPin); 
      delay(sensorValue);

      digitalWrite(anode1[a], LOW);      // LED ausschalten

      digitalWrite(cathode1[c], HIGH);

    }

  }

}



void oneByOne4() {
  
    sensorValue2 = analogRead(sensorPin2); 
  sensorValue2 = map(sensorValue2, sensorMin2, sensorMax2, 0, 5);
  sensorValue2 = constrain(sensorValue2, 0, 5);
    sensorValue3 = analogRead(sensorPin3); 
  sensorValue3 = map(sensorValue3, sensorMin3, sensorMax3, 0, 9);
  sensorValue3 = constrain(sensorValue3, 0, 9);

  for(int c = 0; c < sensorValue2; c++) {          // Alle Ebenen nacheinander

    for(int a = 0; a < sensorValue3; a++) {        // Alle LEDs einer Ebene nacheinander

      digitalWrite(anode1[a], HIGH);     // LED anschalten

      digitalWrite(cathode1[c], LOW);
sensorValue = analogRead(sensorPin); 
      delay(sensorValue);

      digitalWrite(anode1[a], LOW);      // LED ausschalten

      digitalWrite(cathode1[c], HIGH);

    }

  }

}


Talisman 11:16, 27 February 2010 (UTC)