I would probably just turn the port on, wait and then turn if off:
if portb.0 = 1 then
portd.0 = 1 'turn on port d bit 0
PAUSE 100
portd.0 = 0 'turn it back off after 100 ms
endif
modifiying this idea with my variable makes it a one-shot deal, so the output only pulses once on the low-going transistion, but does nothing when the user releases the button.
buttonState VAR BIT
START:
if portb.0 <> buttonState then
buttonState = portb.0
if buttonState = 0 then 'user is pushing on button
portd.0 = 1
PAUSE 100
portd.0 = 0
endif
endif
Unfortunately all of the bits on a PIC are latching. So if you want them to be a one-shot blink, then you have to code them to do it. I would try to avoid using the HIGH and LOW commands, unless you intend to use the basic stamp compatability files. These can add some overhead to your compiled program that goes onto your chip.
The pause command also affects how the PIC performs in real-time as the world has to stop inside the pic for this command to execute.
Bookmarks