Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'PIC Buggy maze navigation for ELEC1601
- 'Paul Chen October 2010
- 'output pin allocation (%76543210)
- '76 = motor B
- '54 = motor A
- '3 = not used
- '2 = LED B
- '1 = LED A
- '0 = piezo sounder
- 'input pin allocation
- '7 = sensor B
- '2 = sensor A
- symbol moveCount = w0
- main:
- let moveCount = 0
- goto move
- move:
- let pins = %01010000
- if pin7 = 1 then
- goto adjust
- end if
- if pin2 = 1 then
- if moveCount = 0 OR moveCount = 1 OR moveCount = 4 OR moveCount = 5 OR moveCount = 6 OR moveCount = 7 OR moveCount = 10 OR moveCount = 11 then
- let moveCount = moveCount + 1
- goto left
- end if
- if moveCount = 2 OR moveCount = 3 OR moveCount = 8 OR moveCount = 9 then
- let moveCount = moveCount + 1
- goto right
- end if
- if moveCount = 12 then
- let moveCount = moveCount + 1
- goto turn
- end if
- if moveCount = 13 OR moveCount = 14 OR moveCount = 17 OR moveCount = 18 OR moveCount = 19 OR moveCount = 20 OR moveCount = 23 OR moveCount = 24 then
- let moveCount = moveCount + 1
- goto right
- end if
- if moveCount = 15 OR moveCount = 16 OR moveCount = 21 OR moveCount = 22 then
- let moveCount = moveCount + 1
- goto left
- end if
- if moveCount = 25 then finish
- end if
- goto move
- left:
- let pins =%00000010
- sound 0,(50,150)
- let pins =%10100100
- pause 150
- let pins =%10010010
- pause 1030
- goto move
- right:
- let pins =%00000010
- sound 0,(50,150)
- let pins =%10100010
- pause 150
- let pins =%01100100
- pause 1030
- goto move
- turn:
- let pins =%00000010
- sound 0,(50,150)
- let pins =%10100010
- pause 150
- let pins =%01100110
- pause 2060
- goto move
- adjust:
- let pins =%10100100
- pause 150
- let pins =%10010100
- pause 150
- goto move
- finish:
- let pins =%00000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement