Rangkaian :
Code List :
'Program Stopwatch$regfile = "m32def.dat" $crystal = 12000000 'deklarasi LCD Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7 Config Lcd = 16 * 2 Cursor Off Cls 'Deklarasi variabel Dim Pengali As Word Dim Detik_1 As Byte Dim Detik As Byte Dim Menit As Byte Dim Jam As Word Dim Status As Byte Dim Status2 As Byte Dim Status3 As Byte 'konfigurasi timer Config Timer0 = Timer , Prescale = 256 Config Debounce = 30 'setting porta Ddra = 0 Porta = 255 'pengaktifan interupsi timer On Ovf0 Int_timer0 'penggantian nama variabel Pin_reset Alias Pina.2 Pin_on_off Alias Pina.1 Pin_capture Alias Pina.0 'setting nilai awal variabel 'Pin_reset = 1 'Pin_on_off = 1 'Pin_capture = 1 Status = 0 Status2 = 1 'pengaktifan timer0 Enable Timer0 Do If Pin_capture = 0 Then Bitwait Pin_capture , Set Incr Status2 Cls Locate 1 , 1 Lcd "BINA ELEKTRONIK" Locate 2 , 1 Lcd Jam ; Locate 2 , 3 Lcd ":" ; Locate 2 , 4 Lcd Menit ; Locate 2 , 6 Lcd ":" ; Locate 2 , 7 Lcd Detik ; Locate 2 , 9 Lcd ":" ; Locate 2 , 10 Lcd Detik_1 ; Locate 2 , 12 Lcd Capture1 End If If Status2 = 2 Then Locate 2 , 13 Lcd "SLIP" End If If Status2 = 2 Then Locate 2 , 11 Lcd " " End If If Pin_on_off = 0 Then Bitwait Pin_on_off , Set Incr Status End If If Pin_reset = 0 Then Pengali = 0 Detik_1 = 00 Locate 2 , 1 Lcd "00" Locate 2 , 4 Lcd "00" Locate 2 , 7 Lcd "00" Locate 2 , 10 Lcd "00" Detik = 00 Menit = 00 Jam = 00 End If If Status > 2 Then Status = 1 End If If Status2 > 2 Then Status2 = 1 Cls End If If Status = 1 Then Enable Interrupts If Status = 2 Then Disable Interrupts If Status2 < 2 Then Locate 1 , 1 Lcd "STOPWATCH" Locate 2 , 1 Lcd Jam ; Locate 2 , 3 Lcd ":" ; Locate 2 , 4 Lcd Menit ; Locate 2 , 6 Lcd ":" ; Locate 2 , 7 Lcd Detik ; Locate 2 , 9 Lcd ":" ; Locate 2 , 10 Lcd Detik_1 ; End If If Status = 2 Then ' tambahan Locate 2 , 13 ' tambahan Lcd "STOP" ' tambahan End If ' tambahan If Status = 1 Then ' tambahan Locate 2 , 13 ' tambahan Lcd ">>>>" ' tambahan End If Loop Int_timer0: Incr Pengali If Pengali > 0 Then Pengali = 0 Incr Detik_1 End If If Detik_1 > 99 Then Detik_1 = 0 Incr Detik End If If Detik > 59 Then Detik = 0 Incr Menit End If If Menit > 59 Then Menit = 0 Incr Jam End If Return
keren gan! sangat membantu bagi pemula yang baru belajar mikrokontroler. thanks ya
BalasHapus