Outils pour utilisateurs

Outils du site


issue86:arduino

Ceci est une ancienne révision du document !


It’s now time to break out the LCD screen and get some off-computer display going on. I have to be honest and admit that it took me about five tries to get the LCD screen to work properly. The example code in the Arduino IDE explicitly states that the LCD needs only about 6 wires. Rubbish! It requires about 12 of the 16 used as it (obviously) requires power, ground, and at least one wire to a potentiometer (pot) or PWM pin to control the screen brightness. After about two tries I was getting a bit frustrated and ended up just pulling all the wires out and starting again. Fifth time lucky! I finally got a “Hello World!” message and could brighten/darken the screen using a 10k pot.

Humidity Sensor I’d previously tinkered with my humidity sensor. That took a bit of investigating to get some decent code as the code with the sensor kit wouldn’t even compile. I eventually found some code here: http://playground.arduino.cc/main/DHT11Lib which is for the DHT11 module (as used by this sensor). As it says on that page, you need to create two files – dht11.h and dht11.cpp – and paste the relevant code (from that page) into the two files. Now I can compile the code from that page to get a working humidity sensor which displays the temperature and humidity to the serial display in the Arduino IDE. Wiring up the sensor was easy enough as it needs only 5v (middle pin, not labelled), - (ground), and the S(ensor) pin going to the Arduino.

Assemble! With those two working (independently) it was time to try and combine the code (and parts) into one board, and create a digital thermometer. It was easier than I had expected. I opened the humidity sensor code and simply copied over the LCD include, initialisation line, and included the humidity variables in the lcd.print commands – and voila! My code (for your enjoyment) is at: http://pastebin.com/jtkK38ES As you can see, the degrees Centigrade ('C) isn’t displaying quite properly. A kind Redditor messaged me the code shown left (which I haven’t tested as yet). Here is a cool tool that allows you to create your own custom characters: http://fusion94.org/lcdchargen/

issue86/arduino.1419113437.txt.gz · Dernière modification : 2014/12/20 23:10 de d52fr