Metainformationen zur Seite
  •  

Countdown

So geht's

Schaltplan:

Code:

int x = 9;
int Pins[8] = {2,3,4,5,6,7,8,9};
int a,b,c,d,e,f,g,h;

void Berechnen(int x) {
  int Wert[8];
 Wert[0] = (x-1)*(x-4);
 Wert[1] = (x-1)*(x-2)*(x-3)*(x-7);
 Wert[2] = (x-5)*(x-6);
 Wert[3] = x*(x-1)*(x-7);
 Wert[4] = (x-1)*(x-3)*(x-4)*(x-5)*(x-7)*(x-9);
 Wert[5] = (x-2);
 Wert[6] = (x-1)*(x-4)*(x-7);
 Wert[7] = x*(x-1)*(x-2)*(x-3)*(x-4)*(x-5)*(x-7)*(x-8);

 for(int i = 0; i < 8; i++) {
  digitalWrite(Pins[i], Wert[i]);
 }
}

void setup() {
  for(int i = 0; i < 8; i++) {
    pinMode(Pins[i], OUTPUT);
  }
}


void loop() {
  Berechnen(x);
  delay(1000);
  x--;
  if(x<0){
    x = 9;
  }
}