Différences
Ci-dessous, les différences entre deux révisions de la page.
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 |
+ | * [[https:// | ||
* 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 < | #include < | ||
- | #include " | + | #include " |
#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;// | int8_t volume = 0x1a;// | ||
- | #include < | + | #include < |
#define TRIGGER_PIN | #define TRIGGER_PIN | ||
#define ECHO_PIN | #define ECHO_PIN | ||
#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, | NewPing sonar(TRIGGER_PIN, | ||
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' |
- | digitalWrite(5, HIGH); | + | pinMode(6, OUTPUT); |
+ | digitalWrite(6, HIGH); | ||
delay(500);// | delay(500);// | ||
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, | + | |
digitalWrite(5, | digitalWrite(5, | ||
- | | + | |
+ | delay(8000); | ||
+ | | ||
digitalWrite(5, | digitalWrite(5, | ||
- | | + | digitalWrite(6, |
+ | | ||
} | } | ||
} | } | ||
- | |||
- | |||
</ | </ | ||