Cours:ChenillardShieldCorrection

De troyesGEII
Aller à : navigation, rechercher

Retour à la liste des Tps

Enoncé de TP

void setup()
{
  DDRD = 0xFF;
}


void loop()
{
  static uint8_t leds=1;
  static boolean run=false, sens;
  static boolean etatBpPresent = digitalRead(A4), etatBpPasse;
  PORTD = leds;
  etatBpPasse = etatBpPresent;
  etatBpPresent = digitalRead(A4);
  if ( (etatBpPasse == 1) && (etatBpPresent==0)) run = ! run;
  if (run == true)
  {
    delay(analogRead(A3));
    sens=digitalRead(A5);
    if (sens==1)
      if (leds == 128) leds = 1; else leds <<= 1;
    else
      if (leds == 1) leds = 128; else leds >>= 1;
  }
}