Outils pour utilisateurs

Outils du site


issue93:arduino

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
issue93:arduino [2015/02/28 14:27] – créée andre_domenechissue93:arduino [2015/03/18 17:22] (Version actuelle) andre_domenech
Ligne 1: Ligne 1:
-Last month, I showed you what I had of my automated chicken coop door. Well, as ever, I managed to fix one problem – and then introduce twice as much complexity. My system has now gone from a simple servo and LDR to a full servo, LDR, humidity sensor and LCD screen.+**Last month, I showed you what I had of my automated chicken coop door. Well, as ever, I managed to fix one problem – and then introduce twice as much complexity. My system has now gone from a simple servo and LDR to a full servo, LDR, humidity sensor and LCD screen.
  
 A servo normally goes from zero degrees to 180 degrees and, in the code, we can specify which angle we want the servo to move to. A full servo is (as far as I can gather) somewhere between a motor and a servo. You treat it like a servo in the code, but it’s more like a motor in that it will turn 360 degrees, but you can not specify an angle. This posed quite a problem when I had to run the servo forward to raise the door, then in reverse to lower the door. I eventually solved that problem by a bit of a botch using the open command: A servo normally goes from zero degrees to 180 degrees and, in the code, we can specify which angle we want the servo to move to. A full servo is (as far as I can gather) somewhere between a motor and a servo. You treat it like a servo in the code, but it’s more like a motor in that it will turn 360 degrees, but you can not specify an angle. This posed quite a problem when I had to run the servo forward to raise the door, then in reverse to lower the door. I eventually solved that problem by a bit of a botch using the open command:
Ligne 11: Ligne 11:
 myServo.write(reverse); myServo.write(reverse);
  
-It’s not elegant by any means, but it works.+It’s not elegant by any means, but it works.**
  
-You know the LCD screen from the laser trip-wire project. Implementing that was pretty much a copy/paste job, but with the added complexity of the humidity sensor.+Le mois dernier, je vous ai montré ce que j'avais déjà pour ma porte automatique de poulailler. Eh, bien, comme toujours, quand je réussis à régler un problème, j'y introduis quelque chose de deux fois plus complexe. Mon système est maintenant passé d'un simple servo et une LDR [photorésistance] à un servo complet, une LDR, un détecteur d'humidité et un écran LCD. 
 + 
 +Un servo tourne en général de zéro à 180° et, dans le code, nous pouvons spécifier jusqu'à quel angle nous voulons que le servo bouge. Un servo complet est (pour ce que j'ai pu comprendre) quelque part entre un moteur et un servo. Vous le traitez comme un servo dans le code, mais c'est plutôt comme un moteur car il peut tourner sur 360°, mais vous ne pouvez pas spécifier un angle. Ceci me posa un bon problème quand je devais lancer le servo en avant pour lever la porte, puis en arrière pour baisser la porte. J'ai finalement résolu ce problème avec un truc plus ou moins bâclé en utilisant la commande open : 
 + 
 +myServo.write(openDoor); 
 + 
 +et la commande map pour lui envoyer les nombres à l'envers : 
 + 
 +reverse=map(openDoor,0,1023,180,0); 
 + 
 +myServo.write(reverse); 
 + 
 +Ce n'est vraiment pas élégant, mais ça marche. 
 + 
 +**You know the LCD screen from the laser trip-wire project. Implementing that was pretty much a copy/paste job, but with the added complexity of the humidity sensor.
  
 The humidity sensor is a DHT11 model; simply use an include for the dht11 library. If you don’t have it, the relevant files and info are at: http://playground.arduino.cc/main/DHT11Lib. Implementing the humidity and temperature functions were a bit tricky as it uses some pretty complex maths to convert the usual numbers into something we can read as ⁰C. I’m not even going to pretend I know what these functions are doing. I copied and pasted them from other code I found on the DHT11 page, and on some Google searches. The loop() has a chk where we give it the pin that the sensor is on: The humidity sensor is a DHT11 model; simply use an include for the dht11 library. If you don’t have it, the relevant files and info are at: http://playground.arduino.cc/main/DHT11Lib. Implementing the humidity and temperature functions were a bit tricky as it uses some pretty complex maths to convert the usual numbers into something we can read as ⁰C. I’m not even going to pretend I know what these functions are doing. I copied and pasted them from other code I found on the DHT11 page, and on some Google searches. The loop() has a chk where we give it the pin that the sensor is on:
Ligne 37: Ligne 51:
 Now that I have the prototype made, I just need to put the Arduino Nano (with breadboard) in a plastic tub, and run longer wires out to place the LCD and sensor somewhere convenient. Now that I have the prototype made, I just need to put the Arduino Nano (with breadboard) in a plastic tub, and run longer wires out to place the LCD and sensor somewhere convenient.
  
-My final code for this is at: http://pastebin.com/ES421PHV.+My final code for this is at: http://pastebin.com/ES421PHV.** 
 + 
 +Vous connaissez l'écran LCD du projet de détecteur de mouvement à laser. L'implémentation était surtout un travail de copier/coller, mais avec la complexité ajoutée du capteur d'humidité. 
 + 
 +Le capteur d'humidité est un modèle DHT11 ; utilisez simplement un include pour la library (bibliothèque) dht11. Si vous ne l'avez pas, les fichiers correspondants et l'info sont disponibles sur : http://playground.arduino.cc/main/DHT11Lib. Installer les fonctions d'humidité et de température est un peu délicat parce qu'elles utilisent des notions mathématiques assez complexes pour convertir les nombres usuels en quelque chose que nous pouvons lire comme des °C. Je ne vais même pas prétendre savoir ce que font ces fonctions. Je les ai copiées/collées d'un autre programme trouvé sur la page DHT11 et après quelques recherches Google. La boucle loop() a un chk où nous lui précisons le picot d'entrée du capteur : 
 + 
 +int chk = DHT11.read(DHT11PIN); 
 + 
 +Ensuite, nous lançons la commande switch pour vérifier que le capteur est bien branché (encore une fois, ce n'est pas mon code). Il y a plusieurs lignes pour afficher les valeurs converties à l'écran : 
 + 
 +Serial.print("Humidity (%): "); 
 + 
 +Serial.println((float)DHT11.humidity, 2); 
 + 
 +Serial.print("Temperature (°C): "); 
 + 
 +Serial.println((float)DHT11.temperature, 2); 
 + 
 +Je l'ai conservé car c'est une bonne vérification du fonctionnement du capteur, avant d'ajouter l'écran LCD. A la fin, ce sont les mêmes commandes que pour le détecteur de mouvement à laser, mais en insérant les valeurs du capteur d'humidité. 
 + 
 +lcd.setCursor(0, 1); 
 +lcd.print("Temp. ('C): "); 
 +lcd.print(DHT11.temperature); 
 + 
 +Maintenant que j'ai fait le prototype, j'ai juste besoin de mettre l'Arduino Nano (avec la planche) dans un boîtier plastique et de rallonger les fils pour le placer à un endroit judicieux. 
 + 
 +Mon code final est disponible sur : http://pastebin.com/ES421PHV.**
issue93/arduino.1425130057.txt.gz · Dernière modification : 2015/02/28 14:27 de andre_domenech