issue93:arduino
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue93:arduino [2015/02/28 14:27] – créée andre_domenech | issue93: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' |
+ | |||
+ | Un servo tourne en général de zéro à 180° et, dans le code, nous pouvons spécifier jusqu' | ||
+ | |||
+ | myServo.write(openDoor); | ||
+ | |||
+ | et la commande map pour lui envoyer les nombres à l' | ||
+ | |||
+ | reverse=map(openDoor, | ||
+ | |||
+ | 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:// | 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:// | ||
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:// | + | My final code for this is at: http:// |
+ | |||
+ | Vous connaissez l' | ||
+ | |||
+ | Le capteur d' | ||
+ | |||
+ | 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' | ||
+ | |||
+ | Serial.print(" | ||
+ | |||
+ | Serial.println((float)DHT11.humidity, | ||
+ | |||
+ | Serial.print(" | ||
+ | |||
+ | Serial.println((float)DHT11.temperature, | ||
+ | |||
+ | Je l'ai conservé car c'est une bonne vérification du fonctionnement du capteur, avant d' | ||
+ | |||
+ | lcd.setCursor(0, | ||
+ | lcd.print(" | ||
+ | lcd.print(DHT11.temperature); | ||
+ | |||
+ | Maintenant que j'ai fait le prototype, j'ai juste besoin de mettre l' | ||
+ | |||
+ | Mon code final est disponible sur : http:// |
issue93/arduino.1425130057.txt.gz · Dernière modification : 2015/02/28 14:27 de andre_domenech