const int angCapteur0 = 0;
const int angCapteur1 = 1;
const int angCapteur2 = 2;
const int angCapteur3 = 3;

//la valeur lue sera comprise entre 0 et 1023
int valeur0 = 0;
int valeur1 = 0;
int valeur2 = 0;
int valeur3 = 0;

int del = 200; 

boolean b0 = false;
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;

 
void setup() {
 Serial.begin(9600);
}
 
void loop() {

  if(Serial.available()){
    char c = Serial.read();

    switch (c) {
      case '0':
        if(b0){
          b0 = false;
        }else{
          b0 = true;
        }
      break;
      
      case '1':
        if(b1){
          b1 = false;
        }else{
          b1 = true;
        }
      break;
      
      case '2':
        if(b2){
          b2 = false;
        }else{
          b2 = true;
        }
      break;

      case '3':
        if(b3){
          b3 = false;
        }else{
          b3 = true;
        }
      break;

      case 'A':
        del = 0;
      break;

      case 'B':
        del = 100;
      break;

      case 'C':
        del = 200;
      break;

      case 'D':
        del = 300;
      break;

      case 'E':
        del = 400;
      break;

      case 'F':
        del = 500;
      break;
    
    }
  }

  valeur0 = analogRead(angCapteur0);
  valeur1 = analogRead(angCapteur1);
  valeur2 = analogRead(angCapteur2);
  valeur3 = analogRead(angCapteur3);



  if(b0){
    char buffer0[50];
    sprintf(buffer0, "0:%d\n", valeur0);
    Serial.write(buffer0);
  }

  if(b1){
    char buffer1[50];
    sprintf(buffer1, "1:%d\n", valeur1);
    Serial.write(buffer1);
  }

    if(b2){
    char buffer2[50];
    sprintf(buffer2, "2:%d\n", valeur2);
    Serial.write(buffer2);
  }

    if(b3){
    char buffer3[50];
    sprintf(buffer3, "3:%d\n", valeur3);
    Serial.write(buffer3);
  }

  Serial.flush();
  
  delay(del);
}
