const int broche_commande= 12;
int intensite= 0;
float consigne=500;

void setup() {
  Serial.begin (74800);
  pinMode(broche_commande, OUTPUT);
}

void loop(){
  int tension=analogRead(0);
  
  if (tension<consigne and intensite<1023){
    intensite=intensite+1;
  }
  if (tension>consigne and intensite>0){
    intensite=intensite-1;  
  }
  if (intensite > 24){
    analogWrite(broche_commande, intensite);
  }else{
    analogWrite(broche_commande, 0);
  }
  Serial.print(tension);
  Serial.print(", ");
  Serial.print(intensite);
  Serial.println();
}

