YANG SUKA OPREK MIKROKONTROLLER PASTI TIDAK AKAN MAU KETINGGALAN BUAT RUNNING TEXT KAN??
NI LANGSUNG AJA SAYA BAGIKAN LISTNYA KHUSUS PENGGUNA BASCOM AVR :
$regfile = "m16def.dat"
$crystal = 1000000
$hwstack = 32
$swstack = 32
$framesize = 40
Dim Char As Byte , C As Byte , Digit As Byte , L As Byte , I As Byte
Dim X As Word , Y As Integer , Text As String * 50 , T As Byte , Z As Byte
Dim Str_temp As String * 1 , Reeks(250) As Byte , Str_text As String * 50 , Str_len As Byte , Col_len As Byte , R As Byte
Dim Tempmsb As Byte , Templsb As Byte , Tempstr As String * 2
Dim Scroll_speed As Byte
Dim Weekdays As String * 6
Config Sda = Portc.1
Config Scl = Portc.0
Const Ds1307w = &HD0
Const Ds1307r = &HD1
Config Clock = User
Dim Weekday As Byte
Config Date = Dmy , Separator = -
Dim Jam As Byte , Menit As Byte , Detik As Byte
Dim Hari As Byte , Bulan As Byte , Tahun As Byte '
Config Rc5 = Pinc.7
Dim Address As Byte , Command As Byte
Enable Interrupts
Declare Sub Show_text
Declare Sub Show_text1
Declare Sub Set_volt
Declare Sub Set_text
Declare Sub Read_volt
Declare Sub Read_temp
Config Porta = Output
Config Portb = Output
Goto Main
'set text
Sub Set_text
C = 1
For Digit = 1 To Str_len
Str_temp = Mid(str_text , Digit , 1)
Char = Asc(str_temp)
X = Char * 5
For I = 1 To 5
Reeks(c) = Lookup(x , Text_data)
X = X + 1
C = C + 1
Next I
Reeks(c) = 0
C = C + 1
Next Digit
End Sub Set_string
'show text
Sub Show_text
If Str_len > 4 Then
For L = 0 To Col_len
C = 1
For R = 0 To Scroll_speed
Set Portb.0
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Char = C + L
Z = Reeks(char)
Porta = Not Z
Waitus 600
C = C + 1
Reset Portb.0
For X = 1 To 40
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Char = C + L
Z = Reeks(char)
Porta = Not Z
Waitus 600
C = C + 1
Next X
C = 1
Next R
Next L
Gosub A
Else
For L = 0 To Col_len
C = 1
For R = 1 To Scroll_speed
Set Portb.0
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Z = Reeks(c)
Porta = Not Z
Waitus 600
C = C + 1
Reset Portb.0
For X = 1 To 40
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Z = Reeks(c)
Waitus 600
C = C + 1
Next X
C = 1
Next R
Next L
Gosub A
End If
End Sub Show_text
'---------------------
Main:
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Do
Gosub Getdatetime
Str_text = " " + Time$ + " " + Weekdays + " " + Date$ + " " 'Text
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Waitms 1
Call Show_text
Loop
End
Text_data:
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 '
Data 0 , 0 , 0 , 0 , 0 'space
Data 0 , 0 , 95 , 0 , 0 '!
Data 0 , 7 , 0 , 7 , 0 '''
Data 20 , 127 , 20 , 127 , 20 '#
Data 36 , 42 , 127 , 42 , 18 '$
Data 39 , 21 , 107 , 84 , 114 '%
Data 54 , 73 , 86 , 32 , 80 '&
Data 0 , 0 , 11 , 7 , 0 ''
Data 0 , 28 , 34 , 65 , 0 ' (
Data 0 , 65 , 34 , 28 , 0 ')
Data 42 , 28 , 127 , 28 , 42 '*
Data 8 , 8 , 62 , 8 , 8 '+
Data 0 , 88 , 56 , 0 , 0 ',
Data 8 , 8 , 8 , 8 , 8 '-
Data 0 , 96 , 96 , 0 , 0 '.
Data 32 , 16 , 8 , 4 , 2 '/
Data 62 , 81 , 73 , 69 , 62 '0
Data 0 , 66 , 127 , 64 , 0 '1
Data 114 , 73 , 73 , 73 , 70 '2
Data 34 , 65 , 73 , 73 , 54 '3
Data 24 , 20 , 18 , 127 , 16 '4
Data 39 , 69 , 69 , 69 , 57 '5
Data 60 , 74 , 73 , 73 , 48 '6
Data 1 , 113 , 9 , 5 , 3 '7
Data 54 , 73 , 73 , 73 , 54 '8
Data 6 , 73 , 73 , 41 , 30 '9
Data 0 , 54 , 54 , 0 , 0 ':
Data 0 , 91 , 59 , 0 , 0 ';
Data 8 , 20 , 34 , 65 , 0 '<
Data 20 , 20 , 20 , 20 , 20 '=
Data 0 , 65 , 34 , 20 , 8 '>
Data 2 , 1 , 81 , 9 , 6 '?
Data 50 , 73 , 121 , 65 , 62 '@
Data 124 , 18 , 17 , 18 , 124 'A
Data 65 , 127 , 73 , 73 , 62 'B
Data 62 , 65 , 65 , 65 , 34 'C
Data 65 , 127 , 65 , 65 , 62 'D
Data 127 , 73 , 73 , 65 , 65 'E
Data 127 , 9 , 9 , 1 , 1 'F
Data 62 , 65 , 73 , 73 , 58 'G
Data 127 , 8 , 8 , 8 , 127 'H
Data 0 , 65 , 127 , 65 , 0 'I
Data 32 , 64 , 65 , 63 , 1 'J
Data 127 , 8 , 20 , 34 , 65 'K
Data 127 , 64 , 64 , 64 , 64 'L
Data 127 , 2 , 12 , 2 , 127 'M
Data 127 , 2 , 4 , 8 , 127 'N
Data 62 , 65 , 65 , 65 , 62 'O
Data 127 , 9 , 9 , 9 , 6 'P
Data 62 , 65 , 65 , 33 , 94 'Q
Data 127 , 9 , 25 , 41 , 70 'R
Data 38 , 73 , 73 , 73 , 50 'S
Data 1 , 1 , 127 , 1 , 1 'T
Data 63 , 64 , 64 , 64 , 63 'U
Data 7 , 24 , 96 , 24 , 7 'V
Data 127 , 32 , 24 , 32 , 127 'W
Data 99 , 20 , 8 , 20 , 99 'X
Data 3 , 4 , 120 , 4 , 3 'Y
Data 97 , 81 , 73 , 69 , 67 'Z
Data 0 , 127 , 65 , 65 , 0 '[
Data 2 , 4 , 8 , 16 , 32 '\
Data 0 , 65 , 65 , 127 , 0 ']
Data 4 , 2 , 1 , 2 , 4 '^
Data 64 , 64 , 64 , 64 , 64 '_
Data 0 , 0 , 7 , 11 , 0 ''
Data 32 , 84 , 84 , 84 , 56 'a
Data 127 , 40 , 68 , 68 , 56 'b
Data 0 , 56 , 68 , 68 , 68 'c
Data 56 , 68 , 68 , 40 , 127 'd
Data 56 , 84 , 84 , 84 , 24 'e
Data 8 , 126 , 9 , 9 , 2 'f
Data 8 , 84 , 84 , 84 , 60 'g
Data 127 , 16 , 8 , 8 , 112 'h
Data 0 , 68 , 125 , 0 , 0 'i
Data 32 , 64 , 68 , 61 , 0 'j
Data 0 , 127 , 16 , 40 , 68 'k
Data 0 , 65 , 127 , 64 , 0 'l
Data 124 , 4 , 120 , 4 , 120 'm
Data 124 , 8 , 4 , 4 , 120 'n
Data 56 , 68 , 68 , 68 , 56 'o
Data 124 , 20 , 20 , 20 , 8 'p
Data 8 , 20 , 20 , 20 , 124 'q
Data 124 , 8 , 4 , 4 , 8 'r
Data 72 , 84 , 84 , 84 , 36 's
Data 0 , 4 , 63 , 68 , 68 't
Data 60 , 64 , 64 , 32 , 124 'u
Data 28 , 32 , 64 , 32 , 28 'v
Data 60 , 64 , 60 , 64 , 60 'w
Data 68 , 40 , 16 , 40 , 68 'x
Data 12 , 80 , 80 , 80 , 60 'y
Data 68 , 100 , 84 , 76 , 68 'z
Data 0 , 8 , 54 , 65 , 0 '{
Data 0 , 0 , 119 , 0 , 0 '|
Data 0 , 65 , 54 , 8 , 0 '}
Data 2 , 1 , 2 , 4 , 2 '~
Data 42 , 85 , 42 , 85 , 42 '
Getdatetime:
I2cstart
I2cwbyte Ds1307w
I2cwbyte &H0
I2cstart
I2cwbyte Ds1307r
I2crbyte _sec , Ack
I2crbyte _min , Ack
I2crbyte _hour , Ack
I2crbyte Weekday , Ack
I2crbyte _day , Ack
I2crbyte _month , Ack
I2crbyte _year , Nack
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
_month = Makedec(_month) : _day = Makedec(_day) : _year = Makedec(_year)
If Weekday = 1 Then Weekdays = "sabtu"
If Weekday = 2 Then Weekdays = "Minggu"
If Weekday = 3 Then Weekdays = "Senin"
If Weekday = 4 Then Weekdays = "Selasa"
If Weekday = 5 Then Weekdays = "Rabu"
If Weekday = 6 Then Weekdays = "Kamis"
If Weekday = 7 Then Weekdays = "Jumat"
Return
'Setdate:
' _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year)
' I2cstart
' I2cwbyte Ds1307w
' I2cwbyte 4
' I2cwbyte _day
' I2cwbyte _month
' I2cwbyte _year
' I2cstop
'Return
'Settime:
' _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
' I2cstart
' I2cwbyte Ds1307w
' I2cwbyte 0
' I2cwbyte _sec
' I2cwbyte _min
' I2cwbyte _hour
' I2cstop
'Return
A:
Getrc5(address , Command)
If Address = Address Then
If Command = 250 Or Command = 122 Then
Gosub Baca_tombol
End If
End If
Return
Baca_tombol:
Do
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Str_text = "Set Mnt: " + Str(menit)
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Getrc5(address , Command)
If Address = Address Then
If Command = 86 Or Command = 214 Then
Menit = Menit + 1
Detik = 0
End If
End If
If Address = Address Then
If Command = 85 Or Command = 213 Then
Menit = Menit - 1
Detik = 0
End If
End If
If Address = Address Then
If Command = 250 Or Command = 122 Then 'ok
Gosub Jam1
End If
End If
If Jam > 23 Then
Jam = 0
Elseif Menit > 59 Then
Menit = 0
Elseif Detik > 59 Then
Detik = 0
End If
_sec = Makebcd(detik) : _min = Makebcd(menit) : _hour = Makebcd(jam)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 0
I2cwbyte _sec
I2cwbyte _min
I2cwbyte _hour
I2cstop
Loop
Jam1:
Do
Str_text = "Set Jam: " + Str(jam)
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Getrc5(address , Command)
If Address = Address Then
If Command = 86 Or Command = 214 Then
Jam = Jam + 1
Detik = 0
End If
End If
If Address = Address Then
If Command = 85 Or Command = 213 Then
Jam = Jam - 1
Detik = 0
End If
End If
If Address = Address Then
If Command = 250 Or Command = 122 Then 'ok
Gosub Hari1
End If
End If
If Jam > 23 Then
Jam = 0
Elseif Menit > 59 Then
Menit = 0
Elseif Detik > 59 Then
Detik = 0
End If
_sec = Makebcd(detik) : _min = Makebcd(menit) : _hour = Makebcd(jam)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 0
I2cwbyte _sec
I2cwbyte _min
I2cwbyte _hour
I2cstop
Loop
Hari1:
Do
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Str_text = "Set Hri :" + Str(hari)
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Getrc5(address , Command)
If Address = Address Then
If Command = 86 Or Command = 214 Then
Hari = Hari + 1
End If
End If
If Address = Address Then
If Command = 85 Or Command = 213 Then
Hari = Hari - 1
End If
End If
If Address = Address Then
If Command = 250 Or Command = 122 Then 'ok
Gosub Bulan1
End If
End If
If Hari > 31 Then
Hari = 1
End If
If Bulan > 12 Then
Bulan = 1
End If
If Tahun > 99 Then
Tahun = 0
End If
_day = Makebcd(hari) : _month = Makebcd(bulan) : _year = Makebcd(tahun)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 4
I2cwbyte _day
I2cwbyte _month
I2cwbyte _year
I2cstop
Loop
Bulan1:
Do
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Str_text = "Set Bln :" + Str(bulan)
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Getrc5(address , Command)
If Address = Address Then
If Command = 86 Or Command = 214 Then
Bulan = Bulan + 1
End If
End If
If Address = Address Then
If Command = 85 Or Command = 213 Then
Bulan = Bulan - 1
End If
End If
If Address = Address Then
If Command = 250 Or Command = 122 Then 'ok
Gosub Tahun1
End If
End If
If Hari > 31 Then
Hari = 1
Elseif Bulan > 12 Then
Bulan = 1
Elseif Tahun > 99 Then
Tahun = 0
End If
_day = Makebcd(hari) : _month = Makebcd(bulan) : _year = Makebcd(tahun)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 4
I2cwbyte _day
I2cwbyte _month
I2cwbyte _year
I2cstop
Loop
Tahun1:
Do
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Str_text = "Set Thn :" + Str(tahun)
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Getrc5(address , Command)
If Address = Address Then
If Command = 86 Or Command = 214 Then
Tahun = Tahun + 1
End If
End If
If Address = Address Then
If Command = 85 Or Command = 213 Then
Tahun = Tahun - 1
End If
End If
If Address = Address Then
If Command = 250 Or Command = 122 Then 'ok
Gosub Device
End If
End If
If Hari > 31 Then
Hari = 1
Elseif Bulan > 12 Then
Bulan = 1
Elseif Tahun > 99 Then
Tahun = 0
End If
_day = Makebcd(hari) : _month = Makebcd(bulan) : _year = Makebcd(tahun)
I2cstart
I2cwbyte Ds1307w
I2cwbyte 4
I2cwbyte _day
I2cwbyte _month
I2cwbyte _year
I2cstop
Loop
Device:
Do
Getrc5(address , Command)
If Address = Address Then
If Command = 250 Or Command = 122 Then
Scroll_speed = 1 'adjust the scroll speed
Call Set_text
Str_text = " Selesai "
Str_len = Len(str_text)
Col_len = Str_len * 6
Call Set_text
Call Show_text1
Gosub Main
End If
End If
Loop
'show text
Sub Show_text1
If Str_len > 4 Then
For L = 0 To 9
C = 1
For R = 1 To Scroll_speed
Set Portb.0
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Char = C + L
Z = Reeks(char)
Porta = Not Z
Waitus 600
C = C + 1
Reset Portb.0
For X = 1 To 40
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Char = C + L
Z = Reeks(char)
Porta = Not Z
Waitus 600
C = C + 1
Next X
C = 1
Next R
Next L
Else
For L = 0 To 9
C = 1
For R = 1 To Scroll_speed
Set Portb.0
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Z = Reeks(c)
Porta = Not Z
Waitus 600
C = C + 1
Reset Portb.0
For X = 1 To 40
Toggle Portb.1
Toggle Portb.1
Toggle Portb.2
Toggle Portb.2
Z = Reeks(c)
Waitus 600
C = C + 1
Next X
C = 1
Next R
Next L
End If
End Sub Show_text1
NI SKEMANYA DAN TAMBAHANNYA :
KLIK UNTUK BUKAGIMANA TERTARIK MAU BUAT.. KEREN KAN??