23 Februari 2013

Jam Digital LCD tampilan Jumbo

Rangkaian Simulator dg Proteus :

Code List : ( Bascom AVR )
'-------------------------------------------------------------------
'Title Block
'Author: Suparnom .Pd
'Date :  Dec 2011
'File name: BigDigitTest.V3
'-------------------------------------------------------------------
$crystal = 8000000                                          'speed of processing
$regfile = "m8535.dat"                                      'our micro
'------------------------------------------------------------------
'setup/configure hardware
Config Porta = Input
Config Portb = Input                                        'switches connected here
Config Pina.4 = Output                                      'backlight

'bascom internal features and functions to make a clock in software

'requires 32,768 Hz crystal on PortC.6 and PortC.7
Config Date = Dmy , Separator = /
Config Clock = Soft , Gosub = Sectic                        'with 1 second interrupt configured
Enable Interrupts                                           'starts the clock

'setup connection of LCD to micro
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Lcd = 20 * 4

'these characters are used to build the bigdigits
Deflcdchar 1 , 32 , 32 , 32 , 1 , 3 , 7 , 15 , 31
Deflcdchar 4 , 31 , 15 , 7 , 3 , 1 , 32 , 32 , 32
Deflcdchar 2 , 32 , 32 , 31 , 31 , 31 , 31 , 31 , 31
Deflcdchar 3 , 32 , 32 , 32 , 16 , 24 , 28 , 30 , 31
Deflcdchar 5 , 31 , 31 , 31 , 31 , 31 , 32 , 32 , 32        ' replace [x] with number (0-7)
'Deflcdchar 5 , 1 , 3 , 7 , 15 , 31 , 32 , 32 , 32
Deflcdchar 6 , 31 , 31 , 31 , 31 , 31 , 32 , 32 , 32
Deflcdchar 7 , 1 , 3 , 7 , 15 , 31 , 31 , 31 , 31
Deflcdchar 0 , 31 , 30 , 28 , 24 , 16 , 32 , 32 , 32

'  Harware Aliases
Lcdbacklight Alias Porta.4
Piezo Alias Portb.0

Yel_btn Alias Pinb.3
Red_btn Alias Pinb.4
Blu_btn Alias Pinb.5
Blk_btn Alias Pinb.6
White_btn Alias Pinb.7

'8. initialise hardware
Cls                                                         'Clears screen
Cursor Off                                                  'no cursor to be displayed on lcd
Set Lcdbacklight                                            'turn on LCD backlight

'------------------------------------------------------------------
' Declare Constants
Const Delay_time = 100
'------------------------------------------------------------------
' Declare Variables

Dim Digitpos As Byte
Dim Seccount As Word
Dim I As Byte

' Initialise Variables
Date$ = "22/07/10"                                          'preset time on powerup
Time$ = "13:10:00"
Digitpos = 1
'------------------------------------------------------------------
' 12. Program starts here
Do
Digitpos = 1
For I = 0 To 9
Gosub Show_bigtime                                  'Show_bigdigit
Waitms 100
Next
Gosub Show_smalltime
Wait 1
Gosub Show_bigtime
Wait 1
Loop
'------------------------------------------------------------------
' Subroutines
Show_smalltime:                                             'Display time in small digits so that title
Locate 2 , 4                                             'and the time can fit in to the lcd.
Lcd "Time: "
Lcd Time$ ; ""
Return

Show_bigtime:
'find the digit in the tens of hours position
I = _hour / 10                                           'e.g. 19/10 = 1 (byte arithmentic!!)
Digitpos = 1
Gosub Show_bigdigit
'find the digit in the units of hours position
I = _hour Mod 10                                         'e,g. 19mod10 = 9 (finds remainder)
Digitpos = 5
Gosub Show_bigdigit

   Locate 2 , 9
Lcd Chr(5)
Locate 3 , 9
Lcd Chr(2)
'find the digit in the tens of minutes position
I = _min / 10                                            'e.g. 21/10 = 2 (byte arithmentic!!)
Digitpos = 11
Gosub Show_bigdigit
'find the digit in the units of minutes position
I = _min Mod 10                                          'e.g 21mod10 = 1 (finds remainder)
Digitpos = 15
Gosub Show_bigdigit
'display the seconds in the bottom corner of the display
Locate 4 , 19
If _sec < 10 Then Lcd "0"
Lcd _sec
Return
Show_bigdigit:
If I = 0 Then Gosub Disp0
If I = 1 Then Gosub Disp1
If I = 2 Then Gosub Disp2
If I = 3 Then Gosub Disp3
If I = 4 Then Gosub Disp4
If I = 5 Then Gosub Disp5
If I = 6 Then Gosub Disp6
If I = 7 Then Gosub Disp7
If I = 8 Then Gosub Disp8
If I = 9 Then Gosub Disp9
Return

Disp0:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)

Return

Disp1:
'line 1
Locate 1 , Digitpos
Lcd " "
Lcd Chr(1)
Lcd " "
'line 2
Locate 2 , Digitpos
Lcd Chr(5)
Lcd Chr(255)
Lcd " "
'line 3
Locate 3 , Digitpos
Lcd " "
Lcd Chr(255)
Lcd " "
'line 4
Locate 4 , Digitpos
Lcd Chr(6)
Lcd Chr(6)
Lcd Chr(6)
Return

Disp2:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd Chr(6)
Lcd " "
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd Chr(7)
Lcd Chr(6)
Lcd Chr(0)
'line 4
Locate 4 , Digitpos
Lcd Chr(6)
Lcd Chr(6)
Lcd Chr(6)
Return
Disp3:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd " "
Lcd Chr(2)
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd " "
Lcd " "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)
Return

Disp4:
'line 1
Locate 1 , Digitpos
Lcd Chr(2)
Lcd " "
Lcd " "
'Line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd Chr(255)
Lcd Chr(255)
Lcd Chr(255)
Locate 4 , Digitpos
Lcd "  "
Lcd Chr(6)
Return

Disp5:
'line 1
Locate 1 , Digitpos
Lcd Chr(2)
Lcd Chr(2)
Lcd Chr(2)
'line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd Chr(2)
Lcd Chr(2)
'line 3
Locate 3 , Digitpos
Lcd Chr(2)
Lcd " "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)
Return

Disp6:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'Line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd Chr(2)
Lcd Chr(3)
'line 3
Locate 3 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)
Return

Disp7:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd "  "
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd "  "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd "  "
Lcd Chr(4)
Return

Disp8:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd Chr(2)
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)
Return
Disp9:
'line 1
Locate 1 , Digitpos
Lcd Chr(1)
Lcd Chr(2)
Lcd Chr(3)
'line 2
Locate 2 , Digitpos
Lcd Chr(255)
Lcd " "
Lcd Chr(255)
'line 3
Locate 3 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(255)
'line 4
Locate 4 , Digitpos
Lcd Chr(4)
Lcd Chr(6)
Lcd Chr(0)
Return

Sectic:
Incr Seccount
Return


View the original article here

Ikuti Blog ini

Langganan

Mau dapet Update-an Blog ini lewat e-mail? Masukkin aja alamat Email kamu disini:

Dikirim Oleh FeedBurner