projets:lacrymo:start

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
projets:lacrymo:start [2021/03/18 11:28]
admin [Notes techniques et matériaux]
projets:lacrymo:start [2022/10/26 09:50] (Version actuelle)
admin [Notes techniques et matériaux]
Ligne 19: Ligne 19:
  
 ===== Notes techniques et matériaux ===== ===== Notes techniques et matériaux =====
-  * arduino uno+  * arduino uno  (2 lib : RedMP3.h  et  NewPing.h) 
 +  * [[https://github.com/ArtronShop/OPEN-SMART-RedMP3]]
   * relai 5v (x8)   * relai 5v (x8)
   * cables jumper   * cables jumper
Ligne 26: Ligne 27:
   * fil nichrome 26g   * fil nichrome 26g
  
 +===== Code arduino =====
 <code c+> <code c+>
-// --------------------------------------------------------------------------- 
-// Example NewPing library sketch that does a ping about 20 times per second. 
-// --------------------------------------------------------------------------- 
 #include <SoftwareSerial.h> #include <SoftwareSerial.h>
-#include "RedMP3.h" +#include "RedMP3.h"  // librairie mp3 sd card player 
 #define MP3_RX 7//RX of Serial MP3 module connect to D7 of Arduino #define MP3_RX 7//RX of Serial MP3 module connect to D7 of Arduino
 #define MP3_TX 8//TX to D8, note that D8 can not be used as RX on Mega2560, you should modify this if you donot use Arduino UNO #define MP3_TX 8//TX to D8, note that D8 can not be used as RX on Mega2560, you should modify this if you donot use Arduino UNO
 MP3 mp3(MP3_RX, MP3_TX); MP3 mp3(MP3_RX, MP3_TX);
- 
 int8_t index  = 0x01;//the first song in the TF card int8_t index  = 0x01;//the first song in the TF card
 int8_t volume = 0x1a;//0~0x1e (30 adjustable level) int8_t volume = 0x1a;//0~0x1e (30 adjustable level)
  
-#include <NewPing.h> +#include <NewPing.h>  // librairie capteur ultrason
 #define TRIGGER_PIN  11  // Arduino pin tied to trigger pin on the ultrasonic sensor. #define TRIGGER_PIN  11  // Arduino pin tied to trigger pin on the ultrasonic sensor.
 #define ECHO_PIN     12  // Arduino pin tied to echo pin on the ultrasonic sensor. #define ECHO_PIN     12  // Arduino pin tied to echo pin on the ultrasonic sensor.
 #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
- 
 int distonce = 0; int distonce = 0;
- 
 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
  
 void setup() { void setup() {
-//  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results. +  pinMode(5, OUTPUT); 
-    pinMode(5, OUTPUT); +  digitalWrite(5, HIGH); // on allume le relai (pour l'initialiser 
-          digitalWrite(5, HIGH);  +  pinMode(6, OUTPUT); 
 +  digitalWrite(6, HIGH); // on allume le relai (pour l'initialiser
  
   delay(500);//Requires 500ms to wait for the MP3 module to initialize     delay(500);//Requires 500ms to wait for the MP3 module to initialize  
Ligne 63: Ligne 57:
   delay(50);                      delay(50);                   
 int distonce = sonar.ping_cm(); int distonce = sonar.ping_cm();
- 
- 
 if (distonce > 1) { if (distonce > 1) {
- +  mp3.playWithVolume(index,volume);  // on joue le premier mp3
-mp3.playWithVolume(index,volume);+
   digitalWrite(5, HIGH);   digitalWrite(5, HIGH);
-  delay(8000);//you should wait for >=50ms between two commands+  digitalWrite(6, HIGH);  // on double les relai par securité au cas ou un ne marche plus. 
 +  delay(8000); 
 +  
   digitalWrite(5, LOW);   digitalWrite(5, LOW);
-    delay(3000);//you should wait for >=50ms between two commands+  digitalWrite(6, LOW); 
 +  delay(3000);
     }     }
 } }
- 
- 
 </code> </code>
  
  • projets/lacrymo/start.1616063332.txt.gz
  • Dernière modification: 2021/03/18 11:28
  • de admin