(Page créée avec « {{ {{tntn|Tuto Details}} |SourceLanguage=none |Language=fr |IsTranslation=0 |Type=Creation |Area=Electronics, Food and Agriculture, Machines and Tools, Recycling and Upcyc... ») |
|||
Ligne 1 : | Ligne 1 : | ||
{{ {{tntn|Tuto Details}} | {{ {{tntn|Tuto Details}} | ||
− | |||
− | |||
− | |||
|Type=Creation | |Type=Creation | ||
|Area=Electronics, Food and Agriculture, Machines and Tools, Recycling and Upcycling, Robotics | |Area=Electronics, Food and Agriculture, Machines and Tools, Recycling and Upcycling, Robotics | ||
Ligne 13 : | Ligne 10 : | ||
|Duration-type=day(s) | |Duration-type=day(s) | ||
|Licences=Attribution (CC BY) | |Licences=Attribution (CC BY) | ||
+ | |SourceLanguage=none | ||
+ | |Language=fr | ||
+ | |IsTranslation=0 | ||
}} | }} | ||
{{ {{tntn|Introduction}} | {{ {{tntn|Introduction}} | ||
Ligne 49 : | Ligne 49 : | ||
}} | }} | ||
{{ {{tntn|Tuto Step}} | {{ {{tntn|Tuto Step}} | ||
+ | |Step_Picture_00=Crok'cat_-_distributeur_de_croquette_automatique_branchement_crok_cat.png | ||
|Step_Title=Programmer la carte Arduino | |Step_Title=Programmer la carte Arduino | ||
− | |Step_Content= | + | |Step_Content=<nowiki>#</nowiki>include <Servo.h> |
+ | |||
+ | /* | ||
+ | |||
+ | * Code d'exemple pour un capteur à ultrasons HC-SR04. | ||
+ | |||
+ | */ | ||
+ | |||
+ | /* Constantes pour les broches */ | ||
+ | |||
+ | const byte TRIGGER_PIN = 2; // Broche TRIGGER | ||
+ | |||
+ | const byte ECHO_PIN = 3; // Broche ECHO | ||
+ | |||
+ | const int ledPin = 13; // pin that the LED is attached to | ||
+ | |||
+ | /* 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; | ||
+ | |||
+ | Servo myservo; | ||
+ | |||
+ | int pos; | ||
+ | |||
+ | /** Fonction setup() */ | ||
+ | |||
+ | void setup() { | ||
+ | |||
+ | /*{ | ||
+ | |||
+ | myservo.attach(9); | ||
+ | |||
+ | myservo.writeMicroseconds(2000); // CW | ||
+ | |||
+ | delay(5000); | ||
+ | |||
+ | myservo.writeMicroseconds(1000); // CCW | ||
+ | |||
+ | delay(3000); | ||
+ | |||
+ | myservo.writeMicroseconds(1500); // stop | ||
+ | |||
+ | delay(100); | ||
+ | |||
+ | }*/ | ||
+ | |||
+ | // initialize the switch pin as an input: | ||
+ | |||
+ | // pinMode(switchPin, INPUT); | ||
+ | |||
+ | // initialize the LED pin as an output: | ||
+ | |||
+ | pinMode(ledPin, OUTPUT); | ||
+ | |||
+ | /* Initialise le port série */ | ||
+ | |||
+ | 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); | ||
+ | |||
+ | } | ||
+ | |||
+ | /** Fonction loop() */ | ||
+ | |||
+ | 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)")); | ||
+ | |||
+ | /* Délai d'attente pour éviter d'afficher trop de résultats à la seconde */ | ||
+ | |||
+ | delay(50); | ||
+ | |||
+ | // si la distance est < 15cm, turn on the LED und motor: | ||
+ | |||
+ | if (distance_mm < 150) { | ||
+ | |||
+ | digitalWrite(ledPin, HIGH); | ||
+ | |||
+ | } else { | ||
+ | |||
+ | digitalWrite(ledPin, LOW); | ||
+ | |||
+ | } | ||
+ | |||
+ | if (distance_mm < 150) { | ||
+ | |||
+ | myservo.attach(9); | ||
+ | |||
+ | myservo.writeMicroseconds(2000); // CW | ||
+ | |||
+ | delay(1110.75); | ||
+ | |||
+ | myservo.writeMicroseconds(1500); | ||
+ | |||
+ | delay(10000); | ||
+ | |||
+ | } | ||
+ | |||
+ | else { | ||
+ | |||
+ | myservo.writeMicroseconds(1500); // stop | ||
+ | |||
+ | delay(100); | ||
+ | |||
+ | } | ||
}} | }} | ||
{{ {{tntn|Tuto Step}} | {{ {{tntn|Tuto Step}} |
Auteur Pot au fab | Dernière modification 9/12/2019 par Clementflipo
Pas encore d'image
chat, distributeur, croquette fr none Creation 0
Electronique :
Fabrication :
Définir le plan de la structure
#include <Servo.h>
/*
* Code d'exemple pour un capteur à ultrasons HC-SR04.
*/
/* Constantes pour les broches */
const byte TRIGGER_PIN = 2; // Broche TRIGGER
const byte ECHO_PIN = 3; // Broche ECHO
const int ledPin = 13; // pin that the LED is attached to
/* 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;
Servo myservo;
int pos;
/** Fonction setup() */
void setup() {
/*{
myservo.attach(9);
myservo.writeMicroseconds(2000); // CW
delay(5000);
myservo.writeMicroseconds(1000); // CCW
delay(3000);
myservo.writeMicroseconds(1500); // stop
delay(100);
}*/
// initialize the switch pin as an input:
// pinMode(switchPin, INPUT);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
/* Initialise le port série */
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);
}
/** Fonction loop() */
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)"));
/* Délai d'attente pour éviter d'afficher trop de résultats à la seconde */
delay(50);
// si la distance est < 15cm, turn on the LED und motor:
if (distance_mm < 150) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
if (distance_mm < 150) {
myservo.attach(9);
myservo.writeMicroseconds(2000); // CW
delay(1110.75);
myservo.writeMicroseconds(1500);
delay(10000);
}
else {
myservo.writeMicroseconds(1500); // stop
delay(100);
}
Imprimer le tourniquet, découper la boite de conserve à la taille de celui-ci
Découper le bois, la bouteille et le carton pour obtenir la boite
Intégrer les différents éléments à leur position respective
Trouver un chat pour le test
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #