Here's something untested you can try. Two methods of rapid fire but you also need to add a 330 Ohm resistor between the button and the input so the PIC can sense a press then drive the same pin as an output even if you keep holding the button low.
I used the names pulse_fire and rapid_fire just to make them seperate.
If it does work for you, adjust the PAUSE times to suit your needs.
Here's the schematic to the resistor add on:Code:' This one fires off 5 shots per press or continueously if button held pulse_fire: i=0 ' Reset increment counter TRISIO = %00000001 ' Port 0 input, rest outputs while GPIO.0=1: Wend ' Wait here until button pressed TRISIO = %00000000 ' Port 0 now an output for i=1 to 5 ' Set number of rapid fires per button press low GPIO.0 ' Hold output LOW pause 50 ' Held LOW for 50ms high GPIO.0 ' Turn OFF output pause 50 ' Keep OFF for 50 ms next i ' goto pulse_fire ' Go back, continue if button still pressed or ' wait until pressed again. ' This one just continueously fires as long as button is pushed rapid_fire: TRISIO = %00000001 ' Port 0 input, rest outputs while GPIO.0=1: Wend ' Wait here until button pressed TRISIO = %00000000 ' Port 0 now an output low GPIO.0 ' Hold output LOW pause 50 ' Held LOW for 50ms high GPIO.0 ' Turn OFF output pause 50 ' Keep OFF for 50 ms goto rapid_fire ' Go back, continue as long as button pressed




Bookmarks