This is only a preview of the February 2021 issue of Silicon Chip. You can view 0 of the 112 pages in the full issue. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "":
Items relevant to "Follow-up: Quantum-dot Cellular Automata":
Items relevant to "Battery Multi Logger":
Items relevant to "Arduino-based Adjustable Power Supply":
Items relevant to "Electronic Wind Chimes":
Items relevant to "LCD clock and thermometer":
Items relevant to "DIY laser rangefinder":
Items relevant to "WiFi Snooping with a Raspberry Pi":
Items relevant to "Making Android Apps with App Inventor":
Items relevant to "Making a Compact Virtual Electronics Workbench":
Articles in this series:
Articles in this series:
Purchase a printed copy of this issue for $7.00. |
CIRCUIT NOTEBOOK
Interesting circuit ideas which we have checked but not built and tested. Contributions will be
paid for at standard rates. All submissions should include full name, address & phone number.
LCD clock and thermometer
This circuit demonstrates my userfriendly alphanumeric LCD library
(lcd.c) that can be employed for interfacing an ATmega micro to an LCD in
4-bit mode using just six pins.
All the interface functions of the
LCD library are used in this sample
program, which includes a digital
clock and a thermometer that can show
degrees Celsius or Fahrenheit.
The LCD interface functions include
character printing, user-defined custom characters, writing text, showing
integer numbers, floating-point numbers, scrolling text to the left or right
and clearing the LCD.
The user just needs to select the
data direction register (DDRX) and
therefore the I/O port used to communicate with the LCD. By default, it
is defined as “DDRD” in the “lcd.h”
file with pins PD0-3 mapping to pins
D4-7 on the LCD, and pins PD4 & 5 on
siliconchip.com.au
that port going to the RS and EN lines
of the LCD.
The port used can be changed to
DDRA, DDRB or DDRC. In fact, you can
change which port and pin are used
for each LCD function if necessary.
The type of LCD you are using (16x1,
16x2, 16x4 or 20x4) is also defined in
the “lcd.h file”. You can change the
lines which read “#define lcd_lines
2” and “#define lcd_characters 16” to
different values to suit 1-line, 4-line
or 20-column displays.
The cursor style can also be controlled by changing the number on
the “#define LCD_cursor 0” line to 1
or 2 to show a solid cursor (1) or have
it blink (2). The default value of zero
means that no cursor is visible.
The circuit is designed around an
ATmega328P, a 16x2 alphanumeric
liquid crystal display and an LM35
temperature sensor. When the cir-
Australia’s electronics magazine
cuit is powered up, the clock starts
at midnight. There are two pushbutton switches used to set the time; S2
changes the hours and S3 increments
the minutes value. Internal pull-up
currents allow the micro to sense when
these buttons are pressed, pulling the
pins low.
The LM35 temperature sensor is
used for the thermometer function.
It produces an output of 10mV/°C. In
this circuit, the temperature range is
0-100°C, so the 0-1V output of IC2 is
fed to analog input ADC0 of microcontroller IC1 (pin 23). It converts
this voltage to a digital value and then
scales it for display on the second line
of the LCD.
The units used are defined in the
software file which can be downloaded
from siliconchip.com.au/Shop/6/5754
Mahmood Alimohammadi,
Tehran, Iran. ($75)
February 2021 69
|