Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'PIC Buggy maze navigation for ELEC1601
  2.  
  3. 'Paul Chen October 2010
  4.  
  5. 'output pin allocation (%76543210)
  6. '76 = motor B
  7. '54 = motor A
  8. '3  = not used
  9. '2  = LED B
  10. '1  = LED A
  11. '0  = piezo sounder
  12.  
  13. 'input pin allocation
  14. '7  = sensor B
  15. '2  = sensor A
  16.  
  17.  
  18.  
  19. symbol moveCount = w0
  20.  
  21.  
  22.  
  23. main:
  24.     let moveCount = 0
  25.     goto move
  26.    
  27. move:
  28.     let pins = %01010000
  29.     if pin7 = 1 then
  30.         goto adjust
  31.     end if
  32.     if pin2 = 1 then
  33.         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
  34.             let moveCount = moveCount + 1
  35.             goto left
  36.         end if
  37.         if moveCount = 2 OR moveCount = 3 OR moveCount = 8 OR moveCount = 9 then
  38.             let moveCount = moveCount + 1
  39.             goto right
  40.         end if
  41.         if moveCount = 12 then
  42.             let moveCount = moveCount + 1
  43.             goto turn
  44.         end if
  45.         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
  46.             let moveCount = moveCount + 1
  47.             goto right
  48.         end if
  49.         if moveCount = 15 OR moveCount = 16 OR moveCount = 21 OR moveCount = 22 then
  50.             let moveCount = moveCount + 1
  51.             goto left
  52.         end if
  53.         if moveCount = 25 then finish
  54.     end if
  55.     goto move
  56.  
  57. left:
  58.     let pins =%00000010
  59.     sound 0,(50,150)
  60.     let pins =%10100100
  61.     pause 150
  62.     let pins =%10010010
  63.     pause 1030
  64.     goto move
  65.  
  66. right:
  67.     let pins =%00000010
  68.     sound 0,(50,150)
  69.     let pins =%10100010
  70.     pause 150
  71.     let pins =%01100100
  72.     pause 1030
  73.     goto move
  74.    
  75. turn:
  76.     let pins =%00000010
  77.     sound 0,(50,150)
  78.     let pins =%10100010
  79.     pause 150
  80.     let pins =%01100110
  81.     pause 2060
  82.     goto move
  83.    
  84. adjust:
  85.     let pins =%10100100
  86.     pause 150
  87.     let pins =%10010100
  88.     pause 150
  89.     goto move
  90.    
  91. finish:
  92.     let pins =%00000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement