main:
DIM t as byte
WPU = %00000000 'turn off weak pullups
TRISIO =%00101000 'set GPIO 0,1,2,4 as out and 3,5 as inputs
GPIO = %00000000 'turn off all outputs
CMCON =0x07 'set comparator to off
[COLOR="Red"]IF BUTTON(GPIO,5,0,1)then GOTO up 'check for button press for up
END IF
IF BUTTON(GPIO,3,0,1)then GOTO down 'check for button press for down[/COLOR]
END IF
GOTO main 'if no presses then restart
up:
FOR t = 1 to 5
GPIO = %00010001 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000011 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000110 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010100 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
down:
FOR t = 1 to 5
GPIO = %00010100 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000110 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000011 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010001 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
end.