'Program Line Follower Case &B00111111 : Call Bantingkanan()
Case &B01111111 : Call Bantingkanan()
'Oleh: Fahmizal Case &B00011111 : Call Bantingkanan()
'Mahsiswa Program Diploma Teknik Elektro Case &B00001111 : Call Bantingkanan()
Case &B00000111 : Call Bantingkanan()
'Universitas Gadjah Mada
2007 Case &B11111111 : Call Mundur()
'Program Line Follower dengan 8 sensor
' logika jalan terus walaupun ada rintangan
'Oleh: Fahmizal
'Mahasiswa Program Diploma Teknik Elektro
Case &B10011111 : Call Ok()
'Universitas Gadjah Mada 2007
Case &B11001111 : Call Ok()
Case &B11100111 : Call Ok()
$regfile = "m8535.dat"
Case &B11110011 : Call Ok()
Case &B11111001 : Call Ok()
$crystal = 12000000
Case &B10001111 : Call Ok()
'-------------------------------------------------------------------------------
Case &B11000111 : Call Ok()
Dim B As Byte
Case &B11100011 : Call Ok()
Dim Data1 As Byte
Case &B11110001 : Call Ok()
'-------------------------------------------------------------------------------
Case &B10000111 : Call Ok()
'PENDEFINISIAN PIN MIKRO
Case &B11000011 : Call Ok()
'-------------------------------------------------------------------------------
Case &B11100001 : Call Ok()
Config Portb = Output
Case &B10000011 : Call Ok()
Dirleft1 Alias Portb.3
Case &B11000001 : Call Ok()
Dirleft2 Alias Portb.2
Dirright1 Alias Portb.1
End Select
Dirright2 Alias Portb.0
Loop
End
Config Pina.0 = Input
Config Pina.1 = Input
Sub Terus()
Config Pina.2 = Input
For B = 0 To 8
Config Pina.3 = Input
Reset Dirleft1
Config Pina.4 = Input
Reset Dirright1
Config Pina.5 = Input
Set Dirleft2
Config Pina.6 = Input
Set Dirright2
Config Pina.7 = Input
Call Pwm(1 , 1)
Next
'-------------------------------------------------------------------------------
End Sub
'KONFIGURASI PWM
'-------------------------------------------------------------------------------
Sub Maju()
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear
For B = 0 To 8
Up , Compare B Pwm = Clear Up
Reset Dirleft1
Config Int0 = Rising
Reset Dirright1
Config Int1 = Rising
Set Dirleft2
Set Dirright2
'-------------------------------------------------------------------------------
Call Pwm(1 , 1)
'DEKLARASI RUTIN
Next
'-------------------------------------------------------------------------------
End Sub
Declare Sub Pwm(byval Kiri As Integer , Byval Kanan As Integer)
Sub Kiri()
Declare Sub Maju()
For B = 0 To 8
Declare Sub Terus()
Reset Dirleft1
Declare Sub Kiri()
Reset Dirright1
Declare Sub Bantingkiri()
Set Dirleft2
Declare Sub Kanan()
Set Dirright2
Declare Sub Bantingkanan()
Call Pwm(3 , 5)
Declare Sub Mundur()
Next
Declare Sub Ok()
End Sub
'-------------------------------------------------------------------------------
Sub Bantingkiri()
'rutin utama
For B = 0 To 8
'-------------------------------------------------------------------------------
Reset Dirleft1
Reset Dirright1
Do
Set Dirleft2
Data1 = Pina
Set Dirright2
Select Case Data1
Call Pwm(1 , 255)
Next
Case &B00000000 : Call Terus()
End Sub
Case &B11100111 : Call Maju()
Sub Kanan()
For B = 0 To 8
Case &B11110011 : Call Kiri()
Reset Dirleft1
Case &B11111001 : Call Kiri()
Reset Dirright1
Case &B11111100 : Call Bantingkiri()
Set Dirleft2
Case &B11111110 : Call Bantingkiri()
Set Dirright2
Case &B11111000 : Call Bantingkiri()
Call Pwm(5 , 3)
Case &B11110000 : Call Bantingkiri()
Next
Case &B11100000 : Call Bantingkiri()
End Sub
Case &B11001111 : Call Kanan()
Sub Bantingkanan()
Case &B10011111 : Call Kanan()
For B = 0 To 8
Reset Dirleft1
Reset Dirright1
Set Dirleft2
Set Dirright2
Call Pwm(255 , 1)
Next
End Sub
Sub Mundur()
For B = 0 To 8
Set Dirleft1
Set Dirright1
Reset Dirleft2
Reset Dirright2
Call Pwm(1 , 1)
Next
End Sub
Sub Ok()
For B = 0 To 8
Reset Dirleft1
Reset Dirright1
Set Dirleft2
Set Dirright2
Call Pwm(1 , 1)
Next
End Sub
'-------------------------------------------------------------------------------
' Rutin pengendali sinyal PWM
'-------------------------------------------------------------------------------
Sub Pwm(byval Kiri As Integer , Byval Kanan As Integer)
Pwm1a = Kiri 'portd.5
Pwm1b = Kanan 'portd.4
End Sub