program Prog1
DIM x as byte
DIM y as byte
main:
ANSEL = 0
TRISC = $00
TRISA = $00
PORTA = $20 'Turns on a yellow led at RA5 quickly for initial testing
PORTC = 0
x = 0
y = 0
delay_ms(1) ' delay of 1s
PORTA = 0
while(1)
while (x < 15)
Gosub Forward
x = x + 1
delay_ms(2)
wend
PORTC = 0
PORTA = 0
delay_ms(500)
while (y < 15)
Gosub Reverse
y = y + 1
delay_ms(2)
wend
PORTC = 0
PORTA = 0
delay_ms(500)
x = 0
y = 0
wend
Forward:
PORTA = $05 'STEP 1
PORTC = $10
delay_ms(10)
PORTA = $06 'STEP 2
PORTC = $10
delay_ms(10)
PORTA = $02 'STEP 3
PORTC = $11
delay_ms(10)
PORTA = $01 'STEP 4
PORTC = $11
delay_ms(10)
return
Reverse:
PORTA = $01 'STEP 4
PORTC = $21
delay_ms(10)
PORTA = $02 'STEP 3
PORTC = $21
delay_ms(10)
PORTA = $06 'STEP 2
PORTC = $20
delay_ms(10)
PORTA = $05 'STEP 1
PORTC = $20
delay_ms(10)
return
end.