Lavomatic miniature
Sommaire
Description du Projet
Le lavomatic miniature vous permet de laver les petites voitures de votre enfance très simplement! Il a été réalisé en 2 jour lors du Hackathon ENIB 2019 au Fablab des fabriques du ponant. Il permet de lier la découverte de différents domaines d'activité et de créer un objet inutile et amusant à utiliser.
Matériel
- Un PC avec le logiciel Arduino
- Arduino uno
- 3 servomoteurs continus
- Capteur à ultrason
- Une vingtaine de fils
- Une alimentation externe 5V
- 3 petits rouleaux de peinture
- Planche de bois
Erreur lors de la création de la miniature : Fichier avec des dimensions supérieures à 12,5 MP
Déroulement du projet
Conception de la structure
Partie numérique
On commence par téléverser le programme ci-dessous dans l'arduino.
#include <Servo.h>
/*creation des servomoteurs*/
Servo monservomoteur1;
Servo monservomoteur2;
Servo monservomoteur3;
const byte TRIGGER_PIN =5 ; // Broche TRIGGER
const byte ECHO_PIN = 6; // Broche ECHO
/* Constantes pour le timeout */
const unsigned long MEASURE_TIMEOUT = 25000UL; // 25ms = ~8m à 340m/s
/* Vitesse du son dans l'air en mm/us */
const float SOUND_SPEED = 340.0 / 1000;
void setup() {
Serial.begin(115200);
/* Initialise les broches */
pinMode(TRIGGER_PIN, OUTPUT);
digitalWrite(TRIGGER_PIN, LOW); // La broche TRIGGER doit être à LOW au repos
pinMode(ECHO_PIN, INPUT);
monservomoteur1.attach(2);
monservomoteur2.attach(3);
monservomoteur3.attach(4);
}
void loop() {
/* 1. Lance une mesure de distance en envoyant une impulsion HIGH de 10µs sur la broche TRIGGER */
digitalWrite(TRIGGER_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGGER_PIN, LOW);
/* 2. Mesure le temps entre l'envoi de l'impulsion ultrasonique et son écho (si il existe) */
long measure = pulseIn(ECHO_PIN, HIGH, MEASURE_TIMEOUT);
/* 3. Calcul la distance à partir du temps mesuré */
float distance_mm = measure / 2.0 * SOUND_SPEED;
/* Affiche les résultats en mm, cm et m */
Serial.print(F("Distance: "));
Serial.print(distance_mm);
Serial.print(F("mm ("));
Serial.print(distance_mm / 10.0, 2);
Serial.print(F("cm, "));
Serial.print(distance_mm / 1000.0, 2);
Serial.println(F("m)"));
/*lancement des moteurs*/
if ((distance_mm<100) && (distance_mm!=0))
{
monservomoteur1.write(0);
monservomoteur2.write(0);
monservomoteur3.write(180);
delay(10000);
monservomoteur1.write(90);
monservomoteur2.write(90);
monservomoteur3.write(90);
}
/* Délai d'attente pour éviter d'afficher trop de résultats à la seconde */
delay(500);
}
Pédagogie
Avec ce projet on apprend à:
- Programmer
- Souder sur carte
- Utiliser logiciel de CAO
