CSCE 211, Digital Logic Design
Circuit 2
Due: Thursday, March 20, 2014
Goal: Design an Arduino thermometer. It reads in the temperature value from a DHT11 sensor and outputs the value to two 7-segment displays.
Required:
Arduino board | 1 |
Breadboard | 1 |
Common anode 7-segment display | 2 |
Resistors | 14 |
USB Cable | 1 |
74LS47 | 2 |
Red LED | 1 |
Green LED | 1 |
Yellow LED | 1 |
Wires | many |
Cook Manual
Test temperature sensor
The circuit package includes a DHT11 temperature sensor in the plastic bag. There are 4 pins on the temperature sensor. They are "vcc", "readout", "unused" and "gnd" from left to right. Connect the 4 pins to the breadboard so that they are inserted into 4 adjacent columns on the breadboard.
The "vcc" pin should be connected to +5v (you can connect to either the vcc pin on the Arduino board, or any hole on the red line power bus if you have connected the vcc to the red line).
The "gnd" pin should be connected to gnd (you can connect to either the gnd pin on the Arduino board, or any hole on the blue line ground bus if you have connected the gnd to the blue line).
The "readout" pin outputs the analog temperature / humidity value.
Download: Go to the link http://feed.Virtuabotix.com/?p=239, click the "Documentation & Libraries" tab, and click Download the DHT11 Library and included examples to download the library file for the temperature sensor.
The library file you downloaded is a compressed archive. Decompress it and enter the extracted folder "DHT11_250A". Copy the folder "DHT11" into the path <your_arduino_path>/libraries.
Testing the sensor: Start Arduino Program editor.
Click "File->Examples->DHT11->dht11_functions". It will open the temperature sensor program example.
Power up the sensor and the Arduino board.
Connect the digital pin 2 on Arduino board to the "readout" pin of the temperature sensor.
Upload the program.
After the program is successfully uploaded, click the "Serial Monitor" button (the amplifier icon of the top-right corner) to open the serial monitor terminal. You will see the temperature and humidity values are updated and scrolled on the terminal.
Some explanations of the code
The program first initializes a dht11 instance by declaring it at the beginning (outside all the functions).
dht11 DHT11;
In the setup function, we need to call the initializer of the dht11 instance.
DHT11.attach(port_num).
The port_num is the ID of the pin on the Arduino board which is connected to the "readout" pin on the sensor.
To read value from the sensor, you need to call DHT11.read() and save the value into an integer variable.
Breadboard setup
Set up two 7-segment displays, two 74LS47 chips, and 14 resistors on the breadboard, and set up the connections between the two 7-segment displays and the two 74LS47 chips. (You can refer to the instructions in Circuit Project 1 and the pin maps of 7-segment display and 74LS47 chip to see how to correctly set up the connections between the 7-segment displays and the 74LS47 chips.)
Connect digital pins (3,4,5,6) and (7,8,9,10) to the inputs (A3,A2,A1,A0) of the two 74LS47 chips respectively. The two sets of pins (3,4,5,6) and (7,8,9,10) are used to output the two-digit 8421 BCD temperature value from the Arduino board to the 74LS47 decoder.
The temperature values are read in from the connection between "readout" and Arduino pin 2.
Programming
Refer to the example program to write your own project program which can continuously read in temperature values and output the two-digit Fahrenheit temperature value to the two 7-segment displays.
Circuit Project Requirements
This circuit project will count for 3 points toward your final grade.
To get full points, you need to show the correct indoor temperature. Correctness of each of the two 7-segment displays will count for half of the credits.
Extra credit opportunity
If your design meets the following requirement, you will receive one extra point toward your final grade. In addition to showing the correct indoor temperature, you are also required to add a temperature alert system which includes a red LED, a yellow LED and a green LED on the board. Turn on the corresponding LED according to the following table:
temperature (F) | red | yellow | green |
[70, 80] | 0 | 0 | 1 |
[65, 70) or (80, 85] | 0 | 1 | 0 |
else | 1 | 0 | 0 |
How to light up an LED
Each LED has 2 legs. To light it up, the current must flow into the longer one and flow out from the shorter one. The following is the order of the connection which lights up a LED:
Digital HIGH --> longer leg of LED --> (through the LED) --> shorter leg of LED --> resistor --> gnd
To control the LED by Arduino, you should connect an output pin on the Arduino board to the longer leg of the LED. Setting the output = HIGH will turn on the LED, and setting output = LOW will turn off the LED.
Useful Links
Pin map of common annode 7-segment display