Thermometer with Clock
This project will display the temperature and time over the LCD display. LM35 is used to sense the temperature and the analog out of the LM35 is converted to digital by using the inbuilt ADC on the ATmega16 chip. An software clock is generated and the Time is also display.
Download the Bascom code and the proteus simulation code
Circuit Diagram
Bascom Code
$regfile = "m16def.dat"
Config Portb = Input
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , Rs = Portd.3 , E = Portd.2
Config Timer2 = Timer , Async = On , Prescale = 128
Config Adc = Single , Prescaler = Auto
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Secs As Byte , Minits As Byte , Hours As Byte
Dim A As Word , B As Byte
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Deflcdchar 0 , 12 , 18 , 18 , 12 , 32 , 32 , 32 , 32
Deflcdchar 1 , 32 , 4 , 12 , 28 , 28 , 32 , 32 , 32
Deflcdchar 2 , 32 , 4 , 14 , 31 , 31 , 32 , 32 , 32
Deflcdchar 3 , 32 , 4 , 14 , 31 , 31 , 7 , 6 , 4
Deflcdchar 4 , 32 , 4 , 14 , 31 , 31 , 31 , 14 , 4
Deflcdchar 5 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Start Adc
B = 1
Enable Interrupts
Enable Timer2
On Timer2 K
Start Timer2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Cls
Cursor Off
Do
Loop
End
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
K:
'''''''''''''''''''''''''''''''''''''
A = Getadc(0)
A = A / 2
Locate 2 , 1
Lcd "Temp =" ; A ; Chr(0) ; "c "
Locate 2 , 16
Lcd Chr(b)
Incr B
If B > 6 Then B = 1
'''''''''''''''''''''''''''''''''''''
Incr Secs
If Secs > 59 Then
Incr Minits
Secs = 0
If Minits > 59 Then
Incr Hours
Minits = 0
Secs = 0
If Hours > 23 Then
Hours = 0
Secs = 0
Minits = 0
End If
End If
End If
If Pinb.2 = 1 Then
Secs = 0
Elseif Pinb.0 = 1 Then
Incr Minits
Elseif Pinb.1 = 1 Then
Incr Hours
End If
Locate 1 , 1
If Hours < 10 Then
Lcd "0" ; Hours ; ":"
Else
Lcd Hours ; ":"
End If
If Minits < 10 Then
Lcd "0" ; Minits ; ":"
Else
Lcd Minits ; ":"
End If
If Secs < 10 Then
Lcd "0" ; Secs
Else
Lcd Secs
End If
Return
Download
Similar Posts
- Interface LM35 with Atmega16
- Measure negative temperature with Lm35
- Connect 2 microcontrollers through serial port

6.20.2010 at 12:05 PM
Can you please show the complete connction of LM35.
What is meant by V out ie U2
is it LM35 !, what do you meant by voltage showing in the diagram U2
regards,
Uttam
6.20.2010 at 12:18 PM
Yes U2 is LM35 and the pin2 is the Vout pin.
7.01.2010 at 4:38 PM
hi, i have a question.
how we can make a temperature indicator with LM35 with point. (25.4)
please with BASCOM
7.14.2010 at 2:58 PM
omg...still with this basic...which kill the brain...use C instead, smartier and easier tu understand...
7.22.2010 at 12:51 PM
Hi,
could you help me?!
I`d like to make a project with LM35 & Atmega16 with CodevisionAVR