ENIB 2020 : Coucoumatron : Différence entre versions

De Les Fabriques du Ponant
Aller à : navigation, rechercher
(Page créée avec « ==photo de l'équipe== 600px ==Que fait ce projet ? == ==Liste des composants== * composant 1 * composant 2 * ... ==Code== <pre> ici je p... »)
 
(Liste des composants)
 
(4 révisions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
==photo de l'équipe==
+
==Photo de l’équipe==
 
[[Fichier:Photoenib2018.jpg|600px]]
 
[[Fichier:Photoenib2018.jpg|600px]]
  
 
==Que fait ce projet ? ==
 
==Que fait ce projet ? ==
 +
 +
Lorsqu’on fait coucou (on passe sa main devant le capteur) à la boite, elle répond en faisant coucou à son tour.
  
 
==Liste des composants==
 
==Liste des composants==
  
* composant 1
+
* Arduino
* composant 2
+
* Capteur de distance Ultrasons
* ...
+
* Servomoteur
 +
* Des fils de connexion
 +
* Du carton ou d'autres matériaux pour réaliser la boite et le bras+main
 +
 
 +
[[Fichier:Circuit_Coucoumatron.png|vignette|Cablage réalisé]]
  
 
==Code==
 
==Code==
<pre>
+
 
ici je pose mon code documenté !
+
<code>
</pre>
+
/*
 +
* The circuit:
 +
* * Module HR-SC04 (four pins) or PING))) (and other with
 +
*  three pins), attached to digital pins as follows:
 +
* ---------------------    --------------------
 +
* | HC-SC04 | Arduino |    | 3 pins | Arduino |
 +
* ---------------------    --------------------
 +
* |  Vcc  |  5V    |    |  Vcc  |  5V    |
 +
* |  Trig  |  12    | OR |  SIG  |  13    |
 +
* |  Echo  |  13    |    |  Gnd  |  GND  |
 +
* |  Gnd  |  GND  |    --------------------
 +
* ---------------------
 +
*
 +
* * A servo on pin 5
 +
*
 +
* created 3 Apr 2014
 +
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 +
* modified 23 Jan 2017
 +
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 +
* modified 03 Mar 2017
 +
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 +
* modified 11 Jun 2018
 +
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 +
* modified 20 Jan 2020
 +
* by Nils Van Zuijlen (github: @nils-van-zuijlen)
 +
* This example code is released into the MIT License.
 +
*/
 +
 
 +
#include <Ultrasonic.h>
 +
#include <Servo.h>
 +
 
 +
/*
 +
* Pass as a parameter the trigger and echo pin, respectively,
 +
* or only the signal pin (for sensors 3 pins), like:
 +
* Ultrasonic ultrasonic(13);
 +
*/
 +
Ultrasonic ultrasonic(12, 13);
 +
Servo arm;
 +
int distance;
 +
 +
void setup() {
 +
  Serial.begin(9600);
 +
  arm.attach(5);
 +
  arm.write(10);
 +
}
 +
 +
void loop() {
 +
  // Pass INC as a parameter to get the distance in inches
 +
  distance = ultrasonic.read();
 +
  Serial.println(distance);
 +
  if (distance < 50) {
 +
    Serial.println("Coucou");
 +
    for (int i = 0; i<2; i++) {
 +
      arm.write(100);
 +
      delay(500);
 +
      arm.write(10);
 +
      delay(500);
 +
    }
 +
  }
 +
  delay(500);
 +
}
 +
</code>
  
 
==Catégories==
 
==Catégories==
  
 
[[Catégorie:Enib2020]]
 
[[Catégorie:Enib2020]]

Version actuelle datée du 20 janvier 2020 à 19:48

Photo de l’équipe

Photoenib2018.jpg

Que fait ce projet ?

Lorsqu’on fait coucou (on passe sa main devant le capteur) à la boite, elle répond en faisant coucou à son tour.

Liste des composants

  • Arduino
  • Capteur de distance Ultrasons
  • Servomoteur
  • Des fils de connexion
  • Du carton ou d'autres matériaux pour réaliser la boite et le bras+main
Cablage réalisé

Code

/*
* The circuit:
* * Module HR-SC04 (four pins) or PING))) (and other with
*   three pins), attached to digital pins as follows:
* ---------------------    --------------------
* | HC-SC04 | Arduino |    | 3 pins | Arduino |
* ---------------------    --------------------
* |   Vcc   |   5V    |    |   Vcc  |   5V    |
* |   Trig  |   12    | OR |   SIG  |   13    |
* |   Echo  |   13    |    |   Gnd  |   GND   |
* |   Gnd   |   GND   |    --------------------
* ---------------------
* 
* * A servo on pin 5
*
* created 3 Apr 2014
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 23 Jan 2017
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 03 Mar 2017
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 11 Jun 2018
* by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
* modified 20 Jan 2020
* by Nils Van Zuijlen (github: @nils-van-zuijlen)
* This example code is released into the MIT License.
*/
#include <Ultrasonic.h>
#include <Servo.h>
/*
* Pass as a parameter the trigger and echo pin, respectively,
* or only the signal pin (for sensors 3 pins), like:
* Ultrasonic ultrasonic(13);
*/
Ultrasonic ultrasonic(12, 13);
Servo arm;
int distance;

void setup() {
  Serial.begin(9600);
  arm.attach(5);
  arm.write(10);
}

void loop() {
  // Pass INC as a parameter to get the distance in inches
  distance = ultrasonic.read();
  Serial.println(distance);
  if (distance < 50) {
    Serial.println("Coucou");
    for (int i = 0; i<2; i++) {
      arm.write(100);
      delay(500);
      arm.write(10);
      delay(500);
    }
  }
  delay(500);
}

Catégories