----AJ----
Junior Member level 1
- Joined
- Mar 23, 2013
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,401
unsigned char shots = 0;
void fire (void){
GPIO.B0 = 1; // Start the motor
TMR0 = 0; // Reset the counter (Timer0)
}
void main(void){
TRISIO = 0b0010110; // B1 = Trigger Input switch, B2 = Counter input (Timer0), B4 = Shots Selector Switch
CMCON0 = 7;
ANSEL = 0;
ADCON0 = 0;
OPTION_REG = 0b10111000;
TMR0 = 0;
GPIO.B0 = 0;
while (1){
if (GPIO.B4 == 0) shots = 3; else shots = 1; // select the number of counts before switch off motor
if (TMR0 == shots) GPIO.B0=0; // when counter = shots switch off motor
if (GPIO.B1 == 1) fire(); // trigger
}
}
Hi,
I don't have a circuit proper circuit as I'm just using the demo board which came with the PICK KIT 2
It seems to be working without the debounce code and counting correctly, so at this point I've not bothered with it.QUOTE]
You are wasting your time. Put the debounce code in.
Wait for 4 hours. I will write a code and post it.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?