Inserendo sul serial input una cifra tra 0 e 9, verrà visualizzata sul display.

char numero;

 

void setup()

{

for(int i=6; i<=12; i++){

pinMode(i, OUTPUT);

}

 

Serial.begin(9600);

}

 

void loop()

{

 

if(Serial.available()){

numero=Serial.read();

Serial.println(numero);

switch(numero){

case ‘0’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(6, LOW);

break;

 

    case ‘1’:

digitalWrite(7, HIGH);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, LOW);

digitalWrite(12, LOW);

digitalWrite(6, LOW);

break;

 

case ‘2’:

digitalWrite(7, LOW);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, LOW);

digitalWrite(6, HIGH);

break;

 

case ‘3’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, LOW);

digitalWrite(6, HIGH);

break;

 

 

 

case ‘4’:

digitalWrite(7, HIGH);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, LOW);

digitalWrite(12, HIGH);

digitalWrite(6, HIGH);

break;

 

case ‘5’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(6, HIGH);

break;

 

case ‘6’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, LOW);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(6, HIGH);

break;

 

case ‘7’:

digitalWrite(7, HIGH);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, LOW);

digitalWrite(6, LOW);

break;

 

 

 

case ‘8’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(6, HIGH);

break;

 

case ‘9’:

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

digitalWrite(6, HIGH);

break;

}

}

}