Menu

CODICE

30 Maggio 2018 - IIID gruppo A

int G=11;
int F=2;
int A=3;
int B=4;
int E=5;
int D=6;
int C=7;
int display1=9;
int display2=10;
int display3=8;

void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void showdigit (int n){
switch (n) {

case 0:
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
break;
case 1:
digitalWrite(A,HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
break;
case 2:
digitalWrite(A,LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
break;
case 3:
digitalWrite(A,LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
break;
case 4:
digitalWrite(A,HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
break;
case 5:
digitalWrite(A,LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E,HIGH);
digitalWrite(F,LOW);
digitalWrite(G, LOW);
break;
case 6:
digitalWrite(A,LOW),
digitalWrite(B,HIGH);
digitalWrite(C, LOW);
digitalWrite(D,LOW);
digitalWrite(E,LOW);
digitalWrite(F, LOW);
digitalWrite(G,LOW);
break;
case 7:
digitalWrite(A,LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
break;
case 8:
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
break;
case 9:
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
break;
}
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(display1, HIGH);
digitalWrite(display2, LOW);
digitalWrite(display3, LOW);
showdigit(5);

delay(1);
digitalWrite(display1, LOW);
digitalWrite(display2, HIGH);
digitalWrite(display3, LOW);
showdigit(4);
delay(1);
digitalWrite(display1, LOW);
digitalWrite(display2, LOW);
digitalWrite(display3, HIGH);
showdigit(9);
delay(1);
}

Lascia un commento