tomch
Newbie level 4
Line follower program
Hi there,
I have recently started my own little project to keep me occupied in my spare time. I have recently been getting into writing simple programs using C and C++. I started looking into ways of implimenting written programs into electronics hardware as I have quite a lot of expirence with the design of simple electronic circuits. This is where I stumbled upon assembly language. After looking at some projects that impliment programming into electronics, I decided that a line follower looked like a simple project to start off with.
I found a simple example of a line follower that uses a microcontroller known as a 16f84. I managed to easily build the sensor circuit without any difficulty.
**broken link removed**
After looking over the datasheet for the 16f84 I am able to understand most of what is going on. The thing that is throwing me off is the use of binary code, combined with the delays used at the bottom of the code. Any help with either of these issues will be greatly appreciated. Below is the code that the person has used. Thank you for your time.
#include p16f84a.inc
start: bSf STATUS, RP0
movlw B'11110000'
movwf TRISB
bCf STATUS, RP0
clrf PORTB
repeat: movlw B'000000101'
movwf PORTB
call delay
btfss PORTB,5
call left
btfss PORTB,6
call right
goto repeat
right movlw B'000001000'
movwf PORTB
call delay
return
left movlw B'00000010'
movwf PORTB
call delay
return
delay: clrf 0x01
delay0: clrf 0x01
delay1: decfsz 0x01, 1
goto delay1
delay2: decfsz 0x11, 1
goto delay0
return
END
Hi there,
I have recently started my own little project to keep me occupied in my spare time. I have recently been getting into writing simple programs using C and C++. I started looking into ways of implimenting written programs into electronics hardware as I have quite a lot of expirence with the design of simple electronic circuits. This is where I stumbled upon assembly language. After looking at some projects that impliment programming into electronics, I decided that a line follower looked like a simple project to start off with.
I found a simple example of a line follower that uses a microcontroller known as a 16f84. I managed to easily build the sensor circuit without any difficulty.
**broken link removed**
After looking over the datasheet for the 16f84 I am able to understand most of what is going on. The thing that is throwing me off is the use of binary code, combined with the delays used at the bottom of the code. Any help with either of these issues will be greatly appreciated. Below is the code that the person has used. Thank you for your time.
#include p16f84a.inc
start: bSf STATUS, RP0
movlw B'11110000'
movwf TRISB
bCf STATUS, RP0
clrf PORTB
repeat: movlw B'000000101'
movwf PORTB
call delay
btfss PORTB,5
call left
btfss PORTB,6
call right
goto repeat
right movlw B'000001000'
movwf PORTB
call delay
return
left movlw B'00000010'
movwf PORTB
call delay
return
delay: clrf 0x01
delay0: clrf 0x01
delay1: decfsz 0x01, 1
goto delay1
delay2: decfsz 0x11, 1
goto delay0
return
END