Robot line follower menggunakan Bascom AVR

'--------------------
'Robot Line Follower
'--------------------
$regfile = "m16def.dat"
'Jika menggunakan ATMega8535 maka diganti dengan "m8535.dat"
$crystal = 12000000
'--------------------------
Ddrb.0 = 1                                                  'Sensor Kanan
Portb.0 = 0
Ddrb.1 = 0
Portb.1 = 1

Ddrb.2 = 1                                                  'Sensor Kiri
Portb.2 = 0
Ddrb.3 = 0
Portb.3 = 1

Ddra.0 = 1                                                  'Motor Kanan
Ddra.1 = 1                                                  'Motor Kiri
'--------------------------
Do
   If Pinb.1 = 0 Then
      Porta.0 = 0
      Porta.1 = 1
   Else
      Porta.0 = 1
      Porta.1 = 1
   End If

   If Pinb.3 = 0 Then
      Porta.0 = 1
      Porta.1 = 0
   Else
      Porta.0 = 1
      Porta.1 = 1
   End If

Loop
'--------------------------- end

1 komentar: