$regfile = "m8def.dat"
$crystal = 1000000
'------------------------ lcd -----------------------------------------------
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Pind.0 , E = Pind.1 , Db4 = Pind.2 , Db5 = Pind.3 , Db6 = Pind.4 , Db7 = Pind.5
Cls
'--------------------------- ds 1307 -----------------------------------------
$lib "ds1307clock.lib"
'configure the scl and sda pins
Config Sda = Portd.7
Config Scl = Portd.6
'address of ds1307
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1
'------------------------------ key --------------------------------------------
Config Pinc.1 = Input
Config Pinc.2 = Input
Config Pinc.3 = Input
Config Pinc.4 = Input
'------------------------------------------------------------------------------
Config Debounce = 30
Dim A As Byte , B As Byte , Data1 As Byte , C As Byte
Dim Seco As Byte , Mine As Byte , Hour As Byte
'----------------------------------------------------------------------------
Cursor Off
'-----------------------------
Cls
Locate 1 , 1
Lcd "Jam Digital LCD"
Locate 2 , 1
Lcd "Bina Project"
Wait 2
For A = 1 To 15
Shiftlcd Left
Waitms 30
Next
Cls
'-------------------------------------------------------------------------------
Main:
Do
Gosub Ds1307
Gosub 24_12
Gosub Chekkey
Loop
'-------------------------------------------------------------------------------
Ds1307:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte Seco , Ack 'sec
I2crbyte Mine , Ack ' MINUTES
I2crbyte Hour , Nack ' Hours
I2cstop
Seco = Makedec(seco) : Mine = Makedec(mine) : Hour = Makedec(hour)
If Seco > 59 Then Seco = 0
If Mine > 59 Then Mine = 0
If Hour > 23 Then
Hour = 0
Gosub Seco
End If
Return
'-------------------------------------------------------------------------------
24_12:
If Pinc.4 = 1 Then Gosub Disply_24
If Pinc.4 = 0 Then Gosub Disply_12
Return
'-------------------------------------------------------------------------------
Disply_24:
Locate 1 , 1
Lcd "Jam = " ; Hour ; ":" ;
If Mine < 10 Then
Lcd "0" ; Mine ; ":" ;
Else
Lcd Mine ; ":" ;
End If
If Seco < 10 Then
Lcd "0" ; Seco
Else
Lcd Seco
End If
Locate 2 , 6
Lcd "(24 Jam)"
Return
'-------------------------------------------------------------------------------
Disply_12:
If Hour = 0 Then Hour = 12
If Hour > 12 Then Hour = Hour - 12
Locate 1 , 1
Lcd "Jam = " ; Hour ; ":" ;
If Mine < 10 Then
Lcd "0" ; Mine ; ":" ;
Else
Lcd Mine ; ":" ;
End If
If Seco < 10 Then
Lcd "0" ; Seco
Else
Lcd Seco
End If
Locate 2 , 6
Lcd "(12 Jam)"
Return
'-------------------------------------------------------------------------------
Chekkey:
Debounce Pinc.1 , 0 , Seco , Sub
Debounce Pinc.2 , 0 , Mine , Sub
Debounce Pinc.3 , 0 , Hour , Sub
Return
'---------------------------------------------
Seco:
Incr Seco
If Seco > 59 Then Seco = 0
Seco = Makebcd(seco)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' starting address in 1307
I2cwbyte Seco
I2cstop
Return
'-------------------------------------
Mine:
Incr Mine
If Mine > 59 Then Mine = 0
Mine = Makebcd(mine)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 1 ' starting address in 1307
I2cwbyte Mine
I2cstop
Return
Menu atas
- Beranda
- Galeri
- Tentang saya
- Jam Digital dengan DS1307 dan Animasi 60 buah LED dengan ATMega32
- Program running text dengan 7 segment menggunakan BASCOM-AVR
- Membuat Jam Digital Menggunakan Bahasa C++
- Jam digital dengan P16F84A MCU
- Jam Digital dengan Mikrokontroler ATmega
- Digital Clock using pic18f8680, counters, external clocks
- Robot Pemadam Api (KRCI) dengan KRCI.BS2
- Robot Pemadam Api (KRCI) dengan UVTRON.OSC
- Robot line follower Dengan Fuzzy Logic
- Robot Line follower dengan Assembler
- Robot line follower menggunakan Bascom AVR
- Robot Line Follower menggunakan CodeVisionAVR
- Robot Line Follower Dengan Fuzzy Logic
Tidak ada komentar:
Posting Komentar