0% found this document useful (0 votes)
28 views

Bascom Code: "M16def - Dat"

This document contains code for a BASCOM microcontroller that displays temperature readings from an ADC, a digital clock, and custom characters on a 16x2 LCD display. It initializes ports and timers, defines custom LCD characters, takes continuous ADC readings to display temperature, and uses interrupts to increment the clock and display the time. The code displays the temperature, a changing custom character, and the digital clock on the LCD.

Uploaded by

dannycbs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Bascom Code: "M16def - Dat"

This document contains code for a BASCOM microcontroller that displays temperature readings from an ADC, a digital clock, and custom characters on a 16x2 LCD display. It initializes ports and timers, defines custom LCD characters, takes continuous ADC readings to display temperature, and uses interrupts to increment the clock and display the time. The code displays the temperature, a changing custom character, and the digital clock on the LCD.

Uploaded by

dannycbs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like