TheAce106

Untitled

Aug 26th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. 'PICAXE-08, PICAXE-08M and PICAXE-08M2 PIN SETTINGS
  2. '0 output = Left motor connection
  3. '1 output = Left motor connection
  4. '2 output = Right motor connection
  5. '3 input = Front and rear switch (1 = either switch pressed)
  6. '4 output = Right motor connection
  7. 'Symbols
  8. symbol m_fwd = %00010010 'motor forward
  9. symbol m_lft = %00010001 'motor left
  10. symbol m_rev = %00000101 'motor reverse
  11. symbol m_rgt = %00000110 'motor right
  12. symbol m_stp = %00000000 'motor stop
  13. symbol w_lng = 2000 'wait long
  14. symbol w_stp = 500 'wait stop
  15. symbol w_brf = 100 'wait brief
  16. symbol a_loop = b0
  17. symbol a_pins = b1
  18. symbol a_time = w1
  19. symbol countr = w2 'changes direction if switch has not been pressed for a while
  20. symbol a_wait = w3
  21. 'Initial setup
  22. let dirs = %00010111
  23. if pin3 = 1 then terminate 'Switch pressed when power turned on.
  24. let pins = m_fwd
  25. let a_wait = 10000 '10 second timer if switch not pressed
  26. let a_wait = a_wait / w_brf 'Convert into loop cycles
  27. main_forward:
  28. let pins = m_fwd
  29. let countr = countr + 1
  30. pause w_brf
  31. if countr >= a_wait then skip_forward
  32. if pin3 = 0 then main_forward 'check for switch
  33. skip_forward:
  34. for a_loop = 0 to 4
  35. lookup a_loop,(m_stp,m_rev,m_stp,m_lft,m_stp),a_pins
  36. lookup a_loop,(w_stp,w_lng,w_stp,w_lng,w_stp),a_time
  37. let pins = a_pins
  38. pause a_time
  39. next a_loop
  40. let pins = m_rev
  41. let countr = 0
  42. main_reverse:
  43. let pins = m_rev
  44. let countr = countr + 1
  45. pause w_brf
  46. if countr >= a_wait then skip_reverse
  47. if pin3 = 0 then main_reverse 'check for switch
  48. skip_reverse:
  49. for a_loop = 0 to 4
  50. lookup a_loop,(m_stp,m_fwd,m_stp,m_lft,m_stp),a_pins
  51. lookup a_loop,(w_stp,w_lng,w_stp,w_lng,w_stp),a_time
  52. let pins = a_pins
  53. pause a_time
  54. next a_loop
  55. let pins = m_fwd
  56. let countr = 0
  57. goto main_forward
  58. terminate:
  59. for a_loop = 0 to 8
  60. lookup a_loop,(m_stp,m_fwd,m_stp,m_rev,m_stp,m_fwd,m_stp,m_rev,m_stp),a_pins
  61. lookup a_loop,(w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf),a_time
  62. let pins = a_pins
  63. pause a_time
  64. next
  65. end
Advertisement
Add Comment
Please, Sign In to add comment