Bonjour, pour un projet de vélo électrique avec de multiple fonctions ( vitesse, kilométrage, clignotants, souplesse de conduite et infos batterie ) j'ai réalisé des clignotants pour vélo qui fonctionnent correctement, c'est un projet totalement fini, codé.
Matériel : - 8 leds jaunes ou oranges et leur résistances qui vont bien pour les alimenter en 5V
- 1 carte arduino ( NANO pour moi )
- 1 interrupteur à bascule ( switch ) 3 positions
- 1 interrupteur à bascule ( switch ) 2 positions ( normal )
- 1 alimentation arduino
- et c'est tout !!! ( ici on ne parle pas du boîtier )
/*ce programme permet l'ajout de clignotants et warning sur un véhicule
* matériel: - 8 leds jaunes
* - 8 résistances 180 Ohms pour les leds
* - 1 interrupteur 3 positions ET UN AUTRE 2 POSITIONS
* - 2 résistances peu importe la valeur pour raccorder l'interrupteur à la masse
* - 1 arduino
* - des fils
*
*bien cabler les leds dans l'ordre sinon ce ne sera plus un chenillard : schema clignotant visuel ci dessous
*
* pin12 pin11 pin10 pin9 pin5 pin6 pin7 pin8
* 0 0 0 0 0 0 0 0
* Led4G Led3G Led2G Led1G Led1D Led2D Led3D Led4D
*/
//définie les pins de déclenchement des clignotants et d'arrêt de ceux-ci
int clignotantgauche = 2;
int clignotantdroit = 4;
int warning = 13;
//définie toutes les pins pour clignotants
int Led1D = 5;
int Led2D = 6;
int Led3D = 7;
int Led4D = 8;
int Led1G = 9;
int Led2G = 10;
int Led3G = 11;
int Led4G = 12;
void setup() {
//définie les pins de déclenchement comme entrées = INPUT
pinMode(clignotantgauche, INPUT);
pinMode(clignotantdroit, INPUT);
pinMode(warning, INPUT);
//Définie les pins clignotants comme sortie = OUTPUT
pinMode(Led1D,OUTPUT);
pinMode(Led2D,OUTPUT);
pinMode(Led3D,OUTPUT);
pinMode(Led4D,OUTPUT);
pinMode(Led1G,OUTPUT);
pinMode(Led2G,OUTPUT);
pinMode(Led3G,OUTPUT);
pinMode(Led4G,OUTPUT);
}
void loop() {
while(digitalRead(clignotantgauche) == 1){ // si on active le clignotant gauche chenillard vers la gauche
digitalWrite(Led1G, HIGH);
delay(100);
digitalWrite(Led2G, HIGH);
delay(100);
digitalWrite(Led3G, HIGH);
delay(100);
digitalWrite(Led4G, HIGH);
delay(100);
digitalWrite(Led1G, LOW);
delay(100);
digitalWrite(Led2G, LOW);
delay(100);
digitalWrite(Led3G, LOW);
delay(100);
digitalWrite(Led4G, LOW);
delay(100);
}
while(digitalRead(clignotantdroit) == 1){ //si l'on active le clignotant droit chenillard vers la droite
digitalWrite(Led1D, HIGH);
delay(100);
digitalWrite(Led2D, HIGH);
delay(100);
digitalWrite(Led3D, HIGH);
delay(100);
digitalWrite(Led4D, HIGH);
delay(100);
digitalWrite(Led1D, LOW);
delay(100);
digitalWrite(Led2D, LOW);
delay(100);
digitalWrite(Led3D, LOW);
delay(100);
digitalWrite(Led4D, LOW);
delay(100);
}
//partie warning
while(digitalRead(warning) == 1){ //si l'on active le second switch les deux chenillard s'allument en meme temps
digitalWrite(Led1D, HIGH);
digitalWrite(Led1G, HIGH);
delay(100);
digitalWrite(Led2D, HIGH);
digitalWrite(Led2G, HIGH);
delay(100);
digitalWrite(Led3D, HIGH);
digitalWrite(Led3G, HIGH);
delay(100);
digitalWrite(Led4D, HIGH);
digitalWrite(Led4G, HIGH);
delay(100);
digitalWrite(Led1D, LOW);
digitalWrite(Led1G, LOW);
delay(100);
digitalWrite(Led2D, LOW);
digitalWrite(Led2G, LOW);
delay(100);
digitalWrite(Led3D, LOW);
digitalWrite(Led3G, LOW);
delay(100);
digitalWrite(Led4D, LOW);
digitalWrite(Led4G, LOW);
delay(100);
}
}