Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| projets:pasdesens [2024/04/24 17:45] – etudiant_e | projets:pasdesens [2024/05/23 09:47] (Version actuelle) – etudiant_e | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ======ALKR====== | + | ======ArduinoHC-SR04====== |
| Cette année a été prédominé par une facette/ | Cette année a été prédominé par une facette/ | ||
| Ligne 6: | Ligne 6: | ||
| Pour cela, j'ai imaginé une installation. | Pour cela, j'ai imaginé une installation. | ||
| - | Extérieurement composé en tissu (matière/ | + | Extérieurement composé en tissu (matière/ |
| Expérimenté en cours de programmation, | Expérimenté en cours de programmation, | ||
| - | |||
| ---- | ---- | ||
| - | + | J’établis donc que le projet pour ce cours d' | |
| - | J’établis donc que le projet pour ce cours d' | + | |
| - | Pour cela... | + | |
| **// | **// | ||
| Ligne 54: | Ligne 51: | ||
| //code;// | //code;// | ||
| - | kdo{{projets: | + | *kdo{{projets: |
| {{projets: | {{projets: | ||
| (moyen des 3 HCSR04 pour la variation du volume) | (moyen des 3 HCSR04 pour la variation du volume) | ||
| + | ->ce code est devenu bancale, j'ai donc changé de librairie et fais autrement: | ||
| - | //**Résultat; | + | * New code |
| + | #include < | ||
| + | #include " | ||
| + | #include < | ||
| + | SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5); | ||
| + | #define FPSerial softSerial | ||
| - | {{MP4}} | + | DFRobotDFPlayerMini myDFPlayer; |
| - | [[http://example.com|Lien externe]] | + | |
| + | HCSR04 hc(2, new int[3] | ||
| + | |||
| + | int ActVol = 0; | ||
| + | int NewVol = 0; | ||
| + | |||
| + | double distance_cm, | ||
| + | int samples = 3 ; | ||
| + | boolean Debug = true ; | ||
| + | |||
| + | |||
| + | void setup() | ||
| + | Serial.begin(9600); | ||
| + | FPSerial.begin(9600); | ||
| + | if (!myDFPlayer.begin(FPSerial, | ||
| + | while (true) { | ||
| + | delay(0); | ||
| + | | ||
| + | | ||
| + | |||
| + | myDFPlayer.volume(0); | ||
| + | myDFPlayer.loop(1); | ||
| + | delay(2000); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | |||
| + | // Lecture des distances des capteurs | ||
| + | |||
| + | float c1_distance = hc.dist(0) ; | ||
| + | float c2_distance = hc.dist(1) ; | ||
| + | float c3_distance = hc.dist(2) ; | ||
| + | |||
| + | if (c1_distance == 0.0 ) { | ||
| + | c1_distance = 400; | ||
| + | } | ||
| + | if (c2_distance == 0.0 ) { | ||
| + | c2_distance = 400; | ||
| + | } | ||
| + | if (c3_distance == 0.0 ) { | ||
| + | c3_distance = 400; | ||
| + | } | ||
| + | |||
| + | // Serial.print(c1_distance); | ||
| + | // Serial.print(" | ||
| + | // Serial.print(c2_distance); | ||
| + | // Serial.print(" | ||
| + | // Serial.println(c3_distance); | ||
| + | |||
| + | // Détermination de la distance minimale | ||
| + | float min_distance = min(c2_distance, | ||
| + | // Réglage du volume en fonction de la distance minimale | ||
| + | |||
| + | NewVol | ||
| + | |||
| + | while (NewVol != ActVol) { | ||
| + | Serial.print(min_distance); | ||
| + | Serial.print(" | ||
| + | Serial.print(NewVol); | ||
| + | Serial.print(" | ||
| + | if (NewVol - ActVol > 0) { | ||
| + | ActVol++; | ||
| + | Serial.println(ActVol); | ||
| + | } | ||
| + | else { | ||
| + | ActVol--; | ||
| + | Serial.println(ActVol); | ||
| + | } | ||
| + | |||
| + | myDFPlayer.volume(ActVol); | ||
| + | |||
| + | } | ||
| + | delay(100); | ||
| + | } | ||
| + | |||
| + | // | ||
| + | {{projets: | ||