Build your own temperature meter for fun. This project uses
TC77 digital temperature sensor, a PIC16F871 microcontroller
7-segment 3½ digit LCD. You can study the source code on how to drive
Download source code
The circuit drives the LCD pins with 50% square waves. Each
segment on this LCD is connected to the COM backplane and a separate
pin. When a pin
is driven in phase with the COM pin, the corresponding LCD segment gets
zero voltage, and is off. When a pin is driven in reverse of
the COM pin, the corresponding segment gets an alternating voltage, and
The interrupt routine is called periodically to invert all pins of the
LCD to generate the 50% square wave. The pin states are stored in the
RAM labeled segments_buffer, 5 bytes long. The interrupt also reads the
temperature sensor for the actual values.
The main program gets the temperature value from tc77_ioread, and
calculates the temperature in celsius. All digits of this decimal value
are then converted into the values of the 7 segment of the LCD digits.
This mapping table is located at the label segtable. For example, the
digit 0 turn on the following digits: F, E, D, C, B, A because it sets
bits as "00111111".
The 16 possible fraction values at the last digit are rounded and
mapped to the last digit at the "lookup_frac" table.
the digits in all positions are updated, the "convert_segments"
subroutine will map all the segments into the output pins of the PIC.
For example, segment A of the first digit, called 1A is mapped to the
RD6 pin of the PIC.
||PIC16F871 Microchip microcontroller
||TC77 Microchip digital temperature sensor
||7-segment 3½ digit LCD
||15pF ceramic capacitor
||100nF/6V ceramic capacitor
||CR2032 socket and Lithium battery
||Printed Circuit Board (PCB), strip board or bread-board
housing for the electronics