issue96:arduino
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 | ||
issue96:arduino [2015/05/11 22:21] – d52fr | issue96:arduino [2015/05/15 16:08] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 17: | Ligne 17: | ||
#define ECHO_PIN | #define ECHO_PIN | ||
#define MAX_DISTANCE 200** | #define MAX_DISTANCE 200** | ||
+ | |||
+ | Bon. Nous allons poursuivre le travail du mois dernier en ajoutant le sonar au circuit. | ||
+ | |||
+ | À nouveau, ils sont bon marché, mais assez puissants et aussi, comme nous allons le voir, plutôt précis. | ||
+ | |||
+ | Le capteur que j'ai a 5 picots. Certains n'en ont que quatre, car, même sur le mien, seulement quatre servent. Le 5 V est sur un picot, la masse sur un autre. Les deux autres sont pour l' | ||
+ | |||
+ | Avec le code vu le mois dernier (http:// | ||
+ | |||
+ | Il y a une vidéo du module en pleine action ici : https:// | ||
+ | |||
+ | Permettez-moi de passer en revue quelques lignes de code avec mes notes et mes réflexions : | ||
+ | #include < | ||
+ | |||
+ | Ce qui concerne l' | ||
+ | https:// | ||
+ | |||
+ | #define TRIGGER_PIN | ||
+ | #define ECHO_PIN | ||
+ | #define MAX_DISTANCE 200 | ||
**The three defines are pretty self-explanatory. Three and five are the Arduino pins, and the maximum distance is in centimeters. Some estimations of these units have them hitting a target over 400cm away! | **The three defines are pretty self-explanatory. Three and five are the Arduino pins, and the maximum distance is in centimeters. Some estimations of these units have them hitting a target over 400cm away! | ||
Ligne 29: | Ligne 49: | ||
Maybe this one caught you out last month:** | Maybe this one caught you out last month:** | ||
+ | |||
+ | Les trois define se comprennent d' | ||
+ | |||
+ | Dans la boucle principale, main loop() : | ||
+ | |||
+ | L' | ||
+ | int uS = sonar.ping_cm(); | ||
+ | |||
+ | Nous réglons la couleur (comme on l'a fait le mois dernier) mais ici, nous changeons de police : | ||
+ | myGLCD.setFont(SevenSegNumFont); | ||
+ | |||
+ | La ligne ci-dessous vous a peut-être causé des soucis le mois dernier : | ||
**myGLCD.print(String(uS)+String(" | **myGLCD.print(String(uS)+String(" | ||
Ligne 41: | Ligne 73: | ||
This prints the number in uS (but as a string) to the screen, puts a space after it, and prints it aligned left at line 24. Why a space? Well, when you run it, you’ll see that, without the space, it leaves the old number behind and you can end up going from 13 to 93. It actually means 9 but has only overwritten the 1 from the 13 leaving the three behind. It’s a bad botch, I admit, but that’s why I’m an amateur at this!** | This prints the number in uS (but as a string) to the screen, puts a space after it, and prints it aligned left at line 24. Why a space? Well, when you run it, you’ll see that, without the space, it leaves the old number behind and you can end up going from 13 to 93. It actually means 9 but has only overwritten the 1 from the 13 leaving the three behind. It’s a bad botch, I admit, but that’s why I’m an amateur at this!** | ||
+ | |||
+ | myGLCD.print(String(uS)+String(" | ||
+ | |||
+ | La comprendre m'a demandé un peu de temps. Quand j' | ||
+ | |||
+ | myGLCD.print(uS, | ||
+ | |||
+ | j' | ||
+ | |||
+ | myGLCD.print(String(uS)+String(" | ||
+ | |||
+ | Ceci imprime à l' |
issue96/arduino.1431375692.txt.gz · Dernière modification : 2015/05/11 22:21 de d52fr