Questo la seconda parte di codice:
void Switch_Case_Comando_Ventole()
{ byte comando = 0;
if (Serial2.available())
{
// un byte disponibile - passo a trattarlo
comando = parserizza((byte)Serial2.read());
// tutto il lavoro lo fa la parserizza che restituisce un valore numerico
// 0 per non trovato
// 1 per trovato primo comando
// 2 per trovato.......
}
switch (comando)
{
case 0: //comando non trovato non fa niente
break;
case 1: //TUTTO SPENTO
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 0% duty cycle on Pin 6
pwm.pinDuty( 7, pwm_duty ); // 0% duty cycle on Pin 7
break;
case 2: //VENTOLA SX_3 DX_0
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 75% duty cycle on Pin 6
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 0% duty cycle on Pin 7
break;
case 3: //VENTOLA SX_0 DX_3
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 0% duty cycle on Pin 6
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 75% duty cycle on Pin 7
break;
case 4: //VENTOLA SX_3 DX_3
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 75% duty cycle on Pin 6
pwm.pinDuty( 7, pwm_duty ); // 75% duty cycle on Pin 7
break;
case 5: //VENTOLA SX_2 DX_3
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 50% duty cycle on Pin 6
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 75% duty cycle on Pin 7
break;
case 6: //VENTOLA SX_3 DX_2
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 75% duty cycle on Pin 6
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 50% duty cycle on Pin 7
break;
case 7: //VENTOLA SX_2 DX_0
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 50% duty cycle on Pin 6
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 0% duty cycle on Pin 7
break;
case 8: //VENTOLA SX_0 DX_2
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 0% duty cycle on Pin 6
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 50% duty cycle on Pin 7
break;
case 9: //VENTOLA SX_2 DX_2
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 50% duty cycle on Pin 6
pwm.pinDuty( 7, pwm_duty ); // 50% duty cycle on Pin 7
break;
case 10: //VENTOLA SX_1 DX_2
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 25% duty cycle on Pin 6
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 50% duty cycle on Pin 7
break;
case 11: //VENTOLA SX_2 DX_1
pwm_duty = 130; // 50% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 50% duty cycle on Pin 6
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 25% duty cycle on Pin 7
break;
case 12: //VENTOLA SX_1 DX_1
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 25% duty cycle on Pin 6
pwm.pinDuty( 7, pwm_duty ); // 25% duty cycle on Pin 7
break;
case 13: //VENTOLA SX_0 DX_1
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 0% duty cycle on Pin 6
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 25% duty cycle on Pin 7
break;
case 14: //VENTOLA SX_1 DX_0
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 25% duty cycle on Pin 6
pwm_duty = 255; // 0% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 0% duty cycle on Pin 7
break;
case 15: //VENTOLA SX_3 DX_1
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 75% duty cycle on Pin 6
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 25% duty cycle on Pin 7
break;
case 16: //VENTOLA SX_1 DX_3
pwm_duty = 200; // 25% duty cycle
pwm.pinDuty( 6, pwm_duty ); // 25% duty cycle on Pin 6
pwm_duty = 70; // 75% duty cycle
pwm.pinDuty( 7, pwm_duty ); // 75% duty cycle on Pin 7
break;
default:
break;
}
}