Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'PICAXE-08, PICAXE-08M and PICAXE-08M2 PIN SETTINGS
- '0 output = Left motor connection
- '1 output = Left motor connection
- '2 output = Right motor connection
- '3 input = Front and rear switch (1 = either switch pressed)
- '4 output = Right motor connection
- 'Symbols
- symbol m_fwd = %00010010 'motor forward
- symbol m_lft = %00010001 'motor left
- symbol m_rev = %00000101 'motor reverse
- symbol m_rgt = %00000110 'motor right
- symbol m_stp = %00000000 'motor stop
- symbol w_lng = 2000 'wait long
- symbol w_stp = 500 'wait stop
- symbol w_brf = 100 'wait brief
- symbol a_loop = b0
- symbol a_pins = b1
- symbol a_time = w1
- symbol countr = w2 'changes direction if switch has not been pressed for a while
- symbol a_wait = w3
- 'Initial setup
- let dirs = %00010111
- if pin3 = 1 then terminate 'Switch pressed when power turned on.
- let pins = m_fwd
- let a_wait = 10000 '10 second timer if switch not pressed
- let a_wait = a_wait / w_brf 'Convert into loop cycles
- main_forward:
- let pins = m_fwd
- let countr = countr + 1
- pause w_brf
- if countr >= a_wait then skip_forward
- if pin3 = 0 then main_forward 'check for switch
- skip_forward:
- for a_loop = 0 to 4
- lookup a_loop,(m_stp,m_rev,m_stp,m_lft,m_stp),a_pins
- lookup a_loop,(w_stp,w_lng,w_stp,w_lng,w_stp),a_time
- let pins = a_pins
- pause a_time
- next a_loop
- let pins = m_rev
- let countr = 0
- main_reverse:
- let pins = m_rev
- let countr = countr + 1
- pause w_brf
- if countr >= a_wait then skip_reverse
- if pin3 = 0 then main_reverse 'check for switch
- skip_reverse:
- for a_loop = 0 to 4
- lookup a_loop,(m_stp,m_fwd,m_stp,m_lft,m_stp),a_pins
- lookup a_loop,(w_stp,w_lng,w_stp,w_lng,w_stp),a_time
- let pins = a_pins
- pause a_time
- next a_loop
- let pins = m_fwd
- let countr = 0
- goto main_forward
- terminate:
- for a_loop = 0 to 8
- lookup a_loop,(m_stp,m_fwd,m_stp,m_rev,m_stp,m_fwd,m_stp,m_rev,m_stp),a_pins
- lookup a_loop,(w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf,w_brf),a_time
- let pins = a_pins
- pause a_time
- next
- end
Advertisement
Add Comment
Please, Sign In to add comment