Add files via upload
This commit is contained in:
parent
49f9c20963
commit
684e2b87cf
24
bandeau_led_alimentation.ino
Normal file
24
bandeau_led_alimentation.ino
Normal file
@ -0,0 +1,24 @@
|
||||
int bLed = 3;
|
||||
int gLed = 5;
|
||||
int rLed = 6;
|
||||
int vitesse = 200;
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(bLed, OUTPUT);
|
||||
pinMode(gLed, OUTPUT);
|
||||
pinMode(rLed, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//Red
|
||||
ledControl(20, 20, 20);
|
||||
delay(vitesse);
|
||||
}
|
||||
|
||||
void ledControl (int rIntensity, int gIntensity, int bIntensity) {
|
||||
analogWrite(bLed, bIntensity);
|
||||
analogWrite(rLed, rIntensity);
|
||||
analogWrite(gLed, gIntensity);
|
||||
}
|
30
barre_de_chargement_5leds.ino
Normal file
30
barre_de_chargement_5leds.ino
Normal file
@ -0,0 +1,30 @@
|
||||
int wpin = 6;
|
||||
int rpin = 5;
|
||||
int bpin = 4;
|
||||
int gpin = 3;
|
||||
int ypin = 2;
|
||||
int vitesse = 100;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
pinMode (wpin, LOW);
|
||||
pinMode (rpin, LOW);
|
||||
pinMode (bpin, LOW);
|
||||
pinMode (gpin, LOW);
|
||||
pinMode (ypin, LOW);
|
||||
delay (vitesse);
|
||||
pinMode (wpin, HIGH);
|
||||
delay (vitesse);
|
||||
pinMode (bpin, HIGH);
|
||||
delay (vitesse);
|
||||
pinMode (gpin, HIGH);
|
||||
delay (vitesse);
|
||||
pinMode (ypin, HIGH);
|
||||
delay (vitesse);
|
||||
}
|
||||
|
65
code_capteur_de_position.ino.ino
Normal file
65
code_capteur_de_position.ino.ino
Normal file
@ -0,0 +1,65 @@
|
||||
// debut
|
||||
// vaut mieux des define que des int ou const!!
|
||||
|
||||
#define motor1Pin1 3 // pin 2 (Input 1) du L293D
|
||||
#define motor1Pin2 4 // pin 7 (Input 2) du L293D
|
||||
#define enablePin 9 // pin 1 (Enable 1) du L293D
|
||||
#define Fin_C_Haut 7 // broche 7 du micro-contrôleur se nomme maintenant : Capt1
|
||||
#define Fin_C_Bas 8 // broche 3 du micro-contrôleur se nomme maintenant : Capt2
|
||||
|
||||
// pour une meilleur lisibilité du programme
|
||||
#define CapteurHautOn !digitalRead (Fin_C_Haut) //capteur fermé au repos, donc actif LOW
|
||||
#define CapteurBasOn !digitalRead (Fin_C_Bas) //capteur fermé au repos, donc actif LOW
|
||||
|
||||
// tu dois declarer tes fonctions avant de les utiliser!!
|
||||
void monte() {
|
||||
digitalWrite(motor1Pin1, LOW); // mettre pin 2 a 293D low
|
||||
digitalWrite(motor1Pin2, HIGH); // mettre pin 7 a L293D high
|
||||
}
|
||||
void descend() {
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, LOW); // Mettre pin 7 a L293D low
|
||||
}
|
||||
|
||||
void stop() {
|
||||
digitalWrite(motor1Pin1, HIGH); // Mettre pin 2 a L293D high
|
||||
digitalWrite(motor1Pin2, HIGH); // Mettre pin 7 a L293D low
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// set all the other pins you're using as outputs:
|
||||
pinMode(motor1Pin1, OUTPUT);
|
||||
pinMode(motor1Pin2, OUTPUT);
|
||||
pinMode(enablePin, OUTPUT);
|
||||
|
||||
// initialistaion des capteurs qui sont de preference fermé au repos
|
||||
pinMode(Fin_C_Haut, INPUT); // Capt1 est une broche d'entree
|
||||
pinMode(Fin_C_Bas, INPUT); // Capt2 est une broche d'entree
|
||||
|
||||
stop();
|
||||
// Mettre la broche Enable a high comme ca le moteur tourne
|
||||
digitalWrite(enablePin, HIGH);
|
||||
|
||||
// si au debut on est entre les deux capteur donc on monte
|
||||
if (!CapteurHautOn && !CapteurBasOn) monte();
|
||||
}
|
||||
|
||||
void loop() // boucle principal
|
||||
{
|
||||
//contenu du programme
|
||||
|
||||
// Si fin de course bas ateint
|
||||
if(CapteurBasOn) {
|
||||
stop();
|
||||
delay(750);
|
||||
monte();
|
||||
}
|
||||
|
||||
// Si fin de course haut ateint
|
||||
if(CapteurHautOn) {
|
||||
stop();
|
||||
delay(750);
|
||||
descend();
|
||||
}
|
||||
}
|
||||
//fin
|
53
led_rgb.ino
Normal file
53
led_rgb.ino
Normal file
@ -0,0 +1,53 @@
|
||||
int bLed = 3;
|
||||
int gLed = 5;
|
||||
int rLed = 6;
|
||||
int vitesse = 200;
|
||||
int vitesse1 = 0;
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(bLed, OUTPUT);
|
||||
pinMode(gLed, OUTPUT);
|
||||
pinMode(rLed, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//Red
|
||||
ledControl(120, 0, 0);
|
||||
delay(vitesse);
|
||||
ledControl(0, 0, 0);
|
||||
delay(vitesse1);
|
||||
|
||||
//Green
|
||||
ledControl(0, 120, 0);
|
||||
delay(vitesse);
|
||||
ledControl(0, 0, 0);
|
||||
delay(vitesse1);
|
||||
|
||||
//Blue
|
||||
ledControl(0, 0, 120);
|
||||
delay(vitesse);
|
||||
ledControl(0, 0, 0);
|
||||
delay(vitesse1);
|
||||
|
||||
//Magenta
|
||||
ledControl(120, 0, 120);
|
||||
delay(vitesse);
|
||||
ledControl(0, 0, 0);
|
||||
delay(vitesse1);
|
||||
|
||||
//Yellow
|
||||
ledControl(120, 120, 0);
|
||||
delay(vitesse);
|
||||
ledControl(0, 0, 0);
|
||||
delay(vitesse1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ledControl (int rIntensity, int gIntensity, int bIntensity) {
|
||||
analogWrite(bLed, bIntensity);
|
||||
analogWrite(rLed, rIntensity);
|
||||
analogWrite(gLed, gIntensity);
|
||||
}
|
22
moteur_hydrolique.ino
Normal file
22
moteur_hydrolique.ino
Normal file
@ -0,0 +1,22 @@
|
||||
int vitesse = 3000;
|
||||
int pin1 = 9;
|
||||
int pin2 = 10;
|
||||
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(pin1, OUTPUT);
|
||||
pinMode(pin2, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
digitalWrite (pin1, HIGH);
|
||||
digitalWrite (pin2, LOW);
|
||||
delay (vitesse);
|
||||
digitalWrite (pin1, LOW);
|
||||
digitalWrite (pin2, HIGH);
|
||||
delay (vitesse);
|
||||
|
||||
}
|
21
potentiometre_led.ino
Normal file
21
potentiometre_led.ino
Normal file
@ -0,0 +1,21 @@
|
||||
int potPin= A0;
|
||||
int LEDPin= 9;
|
||||
int readValue;
|
||||
int writeValue;
|
||||
|
||||
void setup() {
|
||||
pinMode(potPin, INPUT);
|
||||
pinMode(LEDPin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
readValue = analogRead(potPin);
|
||||
writeValue = (255./1023.) * readValue;
|
||||
analogWrite(LEDPin, writeValue);
|
||||
Serial.print("Valeur du potentiometre :");
|
||||
Serial.println(writeValue);
|
||||
delay (500);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user