Câblage de la carte Arduino avec la LED: 2 montages possibles
Exo 1:
/*
Blink at ISTY
Turns 3 LED on for one second, then off for one second, repeatedly.
I tested this program at ISTY
25/01/2024
*/
const int led_verte=13, led_orange=12, led_rouge=11;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(led_rouge, OUTPUT);
pinMode(led_verte, OUTPUT);
pinMode(led_orange, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(led_rouge, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led_verte, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led_rouge, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led_verte, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Exo 2:
/*
Blink at ISTY
A pushbutton turns 3 LED on or off
I tested this program at ISTY
25/01/2024
*/
//paramétrage des entrées
const int bp=10;
//paramétrage des sorties
const int led_verte=13, led_orange=12, led_rouge=11;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin bp as an input.
pinMode(bp, INPUT_PULLUP);
// initialize digital pin LED_BUILTIN as an output.
pinMode(led_rouge, OUTPUT);
pinMode(led_verte, OUTPUT);
pinMode(led_orange, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
if (digitalRead(bp) == HIGH)
{
digitalWrite(led_rouge, HIGH);
digitalWrite(led_verte, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100);
}
}
else
{
digitalWrite(led_rouge, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(led_verte, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
}