Comandare ventola PWM con LIN BUS

Il secondo pezzo:

void Switch_Case_Comando ()
{
  switch (comando)
  {
    case 0x0 : //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 0xB :  //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 0xB0:  //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 0xBB: //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 0xBA:  //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 0xAB:  //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 0xA: //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 0xA0: //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 0xAA:  //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 0xA9:  //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 0x9A:  //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 0x99: //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 0x90:  //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 0x9: //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 0x9B:  //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 0xB9:  //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;
  }
}