Étape 5: Faites votre clignotement de la LED !
Combinant la fonction de retard avec la fonction de boucle permet de créer un effet de clignotement avec la LED.
Nous ferons cela en définissant un délai de 1 seconde (1000 millisecondes) entre la LED étant sur (haut) et la LED off (basse).
Nous allons utiliser une variable int nommée retard afin que nous pouvons changer sa valeur sans avoir à taper en nombre encore et encore partout.
Exemple :
// variables
// variables
int GREEN = 3;
int DELAY = 1000;// basic functions
voidsetup()
{
// setup LED modes
// we're specifying that we're going to send information to this LED
pinMode(GREEN, OUTPUT);
}voidloop()
{
// High turns things on
digitalWrite(GREEN, HIGH);
delay(DELAY);
// low turns things off
digitalWrite(GREEN, LOW);
}
int DELAY = 1000;
// basic functions
voidsetup()
{
// setup LED modes
// we're specifying that we're going to send information to this LED
pinMode(GREEN, OUTPUT);
}voidloop()
{
// High turns things on
digitalWrite(GREEN, HIGH);
delay(DELAY);
// low turns things off
digitalWrite(GREEN, LOW);
}