fetitfilou
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 | ||
| fetitfilou [2020/07/21 10:20] – gaziel | fetitfilou [2020/10/27 18:35] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. serge | ||
|---|---|---|---|
| Ligne 2: | Ligne 2: | ||
| A la demande de Buz, création d'un petit filou géant, avec interaction. | A la demande de Buz, création d'un petit filou géant, avec interaction. | ||
| - | |||
| Ligne 9: | Ligne 8: | ||
| * faire de la lumière | * faire de la lumière | ||
| * lancer une interjection de Buz | * lancer une interjection de Buz | ||
| + | |||
| + | |||
| ====fabrication==== | ====fabrication==== | ||
| Ligne 17: | Ligne 18: | ||
| 2 servos | 2 servos | ||
| + | ====Detection==== | ||
| + | Module SR04 ultrason | ||
| - | == Bruit == | + | {{media_04: |
| - | utilisation d'un "DY Player" | + | facile et efficace ! |
| + | librairie Ultrasonic d'Eric Simões | ||
| + | arduino=> | ||
| + | 5V=>VCC | ||
| + | GND=>GND | ||
| + | |||
| + | D2=>Echo | ||
| + | |||
| + | D3=>Trig | ||
| + | |||
| + | |||
| + | ====Bruit==== | ||
| + | |||
| + | utilisation d'un "DY Player" | ||
| + | {{media_04: | ||
| module DY-SV5W | module DY-SV5W | ||
| utilisation en Mode UART ( envoie de commande par le port TX/RX série de l' | utilisation en Mode UART ( envoie de commande par le port TX/RX série de l' | ||
| Sans prise de tête avec la librairie [[https:// | Sans prise de tête avec la librairie [[https:// | ||
| + | |||
| juste 3 fils : | juste 3 fils : | ||
| arduino=> | arduino=> | ||
| + | |||
| 5V=>+5V | 5V=>+5V | ||
| + | |||
| GND=>-5V | GND=>-5V | ||
| + | |||
| D1/ | D1/ | ||
| + | ====Lumière=== | ||
| + | juste une LED RGB ! | ||
| - | bruit et Lumière en attente | + | arduino=> |
| - | ==== code ==== | + | 5V=>V |
| - | <code python> | + | |
| - | #include <Servo.h> | + | D4=>R |
| - | Servo eye1; | + | |
| - | Servo eye2; | + | |
| - | int distance | + | D5=>B |
| - | int duree = 30; // durée de fonctionnement de l' | + | |
| - | const byte POTDISPIN | + | D6=>G |
| - | const byte POTDELAYPIN = 1; // broche | + | |
| - | const byte RELAYPIN = 13; // pin du relais au besoin | ||
| - | const byte EYE1PIN = 10; // broche servo Oeil1 | ||
| - | const byte EYE2PIN = 11; // broche servo Oeil1 | ||
| - | const byte TRIGGER_PIN | + | ==== code ==== |
| - | const byte ECHO_PIN | + | |
| - | const unsigned long MEASURE_TIMEOUT | + | |
| - | const float SOUND_SPEED | + | |
| - | byte eye1Pos = 0; | + | <code python> |
| - | byte eye2Pos = 0; | + | #include < |
| + | //son | ||
| + | #include " | ||
| + | DY::Player player; | ||
| + | int son = 1; | ||
| - | void setup() { | + | //detection SR04 |
| - | | + | #include < |
| - | | + | Ultrasonic ultrasonic(2, 3); |
| + | int distance; | ||
| - | randomSeed(analogRead(0)); | + | // yeux |
| + | #include < | ||
| + | Servo eye1; | ||
| + | Servo eye2; | ||
| + | const byte EYE1PIN = 8; // broche servo Oeil | ||
| + | const byte EYE2PIN = 9; // broche servo Oei1 | ||
| + | byte eye1Pos = 0; | ||
| + | byte eye2Pos = 0; | ||
| - | | + | //lumiere |
| - | pinMode(TRIGGER_PIN, | + | |
| - | digitalWrite(TRIGGER_PIN, | + | |
| - | pinMode(ECHO_PIN, | + | |
| - | Serial.println(" | + | |
| - | eye1.attach(EYE1PIN); | + | const byte COLOR[8] = {0b000, 0b100, 0b010, 0b001, 0b101, 0b011, 0b110, 0b111}; |
| - | eye2.attach(EYE2PIN); | + | |
| - | delay(100); | + | |
| - | eye1.write(eye1Pos); | + | |
| - | eye2.write(eye2Pos); | + | |
| - | Serial.println(" | + | |
| - | } | + | |
| - | void anime() { | + | /* Broches */ |
| + | const byte PIN_LED_R = 4; | ||
| + | const byte PIN_LED_G = 5; | ||
| + | const byte PIN_LED_B = 6; | ||
| + | byte rvb = 0; | ||
| - | switch (duree) { | ||
| + | void setup() { | ||
| + | // | ||
| - | case 1 : // bas | + | player.begin(); |
| - | eye1Pos = 180 ; | + | |
| - | eye2Pos = 0 ; | + | |
| - | break; | + | |
| - | case 2 : // louche 1 | + | |
| - | eye1Pos = 90; | + | |
| - | eye2Pos = -90; | + | |
| - | | + | |
| - | case 3 : // louche 2 | + | |
| - | eye1Pos = -90 ; | + | |
| - | eye2Pos = 90 ; | + | |
| - | case 4 : // haut | + | |
| - | eye1Pos = 0 | + | |
| - | | + | |
| - | | + | |
| - | eye1Pos = int(random(180)); | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| + | displayColor(COLOR[7]); | ||
| } | } | ||
| - | //renvois vrai si la distance en parametre est plus petite en mm | + | void loop() { |
| - | bool declanche( int distance) { | + | |
| - | + | distance = ultrasonic.read(); | |
| - | digitalWrite(TRIGGER_PIN, | + | |
| - | delayMicroseconds(10); | + | |
| - | digitalWrite(TRIGGER_PIN, | + | |
| - | long mesure | + | |
| delay(500); | delay(500); | ||
| - | if (mesure / 2.0 * SOUND_SPEED < distance) { | ||
| - | return true; | ||
| - | } | ||
| - | else { | ||
| - | return false; | ||
| - | } | ||
| + | if (distance < 50) { | ||
| - | } | + | // couleur aleatoire |
| + | // | ||
| + | displayColor(COLOR[int(random(0, | ||
| + | delay(10); | ||
| + | //lecture d'un son aleatoire | ||
| + | son = int(random(1, | ||
| + | player.playSpecified(son); | ||
| + | delay(250); | ||
| + | displayColor(COLOR[int(random(0, | ||
| - | void loop() { | + | // servo position aleatoire |
| + | eye1Pos = int(random(180)); | ||
| + | eye2Pos = int(random(180)); | ||
| + | |||
| + | eye1.write(eye1Pos); | ||
| + | eye2.write(eye2Pos); | ||
| + | delay(50); | ||
| + | displayColor(COLOR[int(random(0, | ||
| + | //attente avant prochaine declanchement | ||
| + | delay(4000); | ||
| - | + | // remise a off | |
| - | if (declanche(300)){ | + | |
| - | + | | |
| - | anime(); | + | |
| - | // son | + | |
| - | // lumiere | + | |
| } | } | ||
| + | } | ||
| + | /** Affiche une couleur */ | ||
| + | void displayColor(byte color) { | ||
| + | // Assigne l' | ||
| + | // Version cathode commune | ||
| + | // | ||
| + | // | ||
| + | // | ||
| + | // Version anode commune | ||
| + | digitalWrite(PIN_LED_R, | ||
| + | digitalWrite(PIN_LED_G, | ||
| + | digitalWrite(PIN_LED_B, | ||
| } | } | ||
| </ | </ | ||
fetitfilou.1595326819.txt.gz · Dernière modification : de gaziel
