Example 1
$regfile "M16DEF.DAT" 'shows type of controller
$crystal = 8000000 'shows frequency of controller
$baud = 9600 'select baud rate for serial communication if you need
$hwstack = 32
$swstack = 8
$framesize = 40
'define LCD Library define connected LCD PIN to controller pin in below code
Config Lcdpin = Pin , E = Portc.1 , Rs = Portc.0 , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
'select type of LCD you use
Config Lcd = 16 * 2
Do 'create do loop for program execution
Cls ' this will clear lCD display every time it executes
Lcd "Bhaumik" 'Lcd Command will Print whatever Text you type in " "
Wait 1 ' will provide delay of 1 second
Loop
End ' hear do loop will end
Example 2
Microcontroller Clock Program
$regfile "M16DEF.DAT"$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 8
$framesize = 40
Config Lcdpin = Pin , E = Portc.1 , Rs = Portc.0 , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Dim Mm As Integer
Dim Hh As Integer
Dim Ss As Integer
Do
Ss = Ss + 1
Wait 1
Cls
If Ss = 60 Then
Mm = Mm + 1
Ss = 0
End If
If Mm = 60 Then
Hh = Hh + 1
Mm = 0
End If
If Hh = 23 And Mm = 59 Then
Ss = 0
Mm = 0
Hh = 0
End If
Locate 1 , 1
Lcd "HH:MM:SS"
Locate 2 , 1
Lcd Hh
Lcd ":"
Lcd Mm
Lcd ":"
Lcd Ss
Loop
End
No comments:
Post a Comment