• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Resource icon

Simple Black Line Follower 2011-05-15

I just have finished my first ROBOT project, a very simple black line follower. I am posting the code and circuit diagram, hope will be useful.

Code:
list p=16f628A
#include<p16f628.inc>
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF &
_INTRC_OSC_NOCLKOUT
ERRORLEVEL -302
cblock 0x20
temp
temp_s
endc
;******************************************************************
org 0x00
goto main
;***********************************INTERRUPT LOOP*****************
org 0X04
inter:
movwf temp
swapf STATUS,w
clrf STATUS
movwf temp_s
btfsc PORTB,0x00
goto loop1
loop2:
movlw b'00000101'
movwf PORTA
btfsc PORTB,0x05
goto loop2
goto loop_x
loop1:
movlw b'10001000'
movwf PORTA
btfsc PORTB,0x00
goto loop1
loop_x
bcf INTCON,0x01
bcf INTCON,0x00
swapf temp_s,w
movwf STATUS
swapf temp,w
retfie
main:
bsf INTCON,0x07 ;Globel interrupt enable(we are using
interr.)
bsf INTCON,0x04
bsf INTCON,0x03 ;RB4-RB7 interrupt on change is
enabled/ in other words these pins will also
work as
;interrupts and interrupt will occur every
time any of these pin changes state
; i.e.:HIGH to LOW or LOW to HIGH, we
can not set it to be on eather one state
change
bcf INTCON, 0x01
bcf INTCON, 0x00 ;Clear RB4-RB7 interrupt flag so,
that another interr. can occur.
;**********************************SET UP THE PORTS *****************
bsf STATUS,RP0 ;switch to BANK 1
movlw b'00100001'
movwf TRISB ;set RB6 & RB5 as input
movlw b'00000000'
movwf TRISA ;setPORT A all output
bcf STATUS,RP0 ;back to BANK 0
movlw 0x07 ;turn comparators off, so HIGH will be
simple HIGH rather than +5V (compared to
supply) so with the LOW
movwf CMCON
Loop:
movlw b'00001001'
movwf PORTA ;set pin 0 of port a HIGH
goto Loop
END
View attachment 44285
Author
c36041254
First release
Last update
Rating
0.00 star(s) 0 ratings

EE World Online Articles

Loading

 
Top