Étape 4 :
p.MsoNormal, li. MsoNormal, div. MsoNormal {marge : 0,0 à; font-size : 12.0pt ; font-family : Times New Roman;} div. Section1 {page : Section1;}
Voici le code pour l’Arduino :
p.MsoNormal, li. MsoNormal, div. MsoNormal {marge : 0,0 à; font-size : 12.0pt ; font-family : Times New Roman;} div. Section1 {page : Section1;}
const int pingPin = 7 ;
longue durée ;
const int ronfleur = 3 ;
void setup()
{pinMode(buzzer,OUTPUT) ;
}
void loop()
{pinMode (pingPin, sortie) ;
digitalWrite (pingPin, basse) ;
delayMicroseconds (2) ;
digitalWrite (pingPin, HIGH) ;
delayMicroseconds (5) ;
digitalWrite (pingPin, basse) ;
pinMode (pingPin, entrée) ;
durée = pulseIn (pingPin, HIGH) ;
Si (durée > 12000 et durée < 20000)
{digitalWrite (sonnerie, HIGH) ;
Delay(2000) ;
digitalWrite (sonnerie, faible) ;
Delay(1000) ;
}
d’autre
{digitalWrite(buzzer,LOW) ;
}}