Acidmods

AcidMods Resources ----- ( These are helpful tools for modding ) => Open Source Code & AcidMods Free Code => Topic started by: Anonamous on September 05, 2010, 09:22:35 AM

Title: Rapid fire Code in C
Post by: Anonamous on September 05, 2010, 09:22:35 AM
does anybody have an example of code written in C. I dont really know where to start with writing it in C and an example would really help.
Title: Re: Rapid fire Code in C
Post by: hyper999 on September 06, 2010, 03:43:54 AM
well to start off your gonna want an interupt routine that occurs somthing like every 1ms then keep the output tristate or high or low depending on the controller type using a counter to count the number of interupts before you swap the output do this repeatadly
Title: Re: Rapid fire Code in C
Post by: Anonamous on September 06, 2010, 08:54:40 AM
ok... well, i think im gonna have my brother do it though since he understands a lot more C than i do. thx ill see what he thinks of that.
Title: Re: Rapid fire Code in C
Post by: d3v1ld0g on September 08, 2010, 08:54:05 PM
The most basic way to do it would be to turn an IO port on/off after a certain amount of delay cycles. Here is a simple one for the PIC12F863 using HiTech C.

Code: [Select]

#include <htc.h>

__CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT & UNPROTECT & MCLRDIS & PWRTEN & WDTDIS & INTCLK);


void init(){

// CHANGE ANALOG CHANNELS TO DIGITAL I/O
CMCON0 = 0x07; // SET COMPARATOR OFF, CIN and COUT PINS AS I/O
    ANSEL = 0x00; // SET ANALOG INPUTS OFF

TRISIO = 0x00; // SETUP I/O BITS
GPIO = 0x00; // SET I/O BITS LOW

}

void main(){

init();

while(1){

GPIO =0x01;

_delay(50000); // delay 50k cycles
                                      //  50k cycles  seems to work good when using the internal clock

GPIO = 0x00;

_delay(50000);

}

}


And just add a switch between GPIO0 and the Right Trigger.

Im a beginner at this stuff just like you, so if i get corrected, listen to them.
Title: Re: Rapid fire Code in C
Post by: hyper999 on September 11, 2010, 05:35:51 PM
Yes that will work but for rapid fire you want to switch between tristate and the unpressed state of the trigger ( high or low depending on controller type ) so that when the trigger is pressed the pic then repeatedly forces it unpressed without you having to physically unpress it
Title: Re: Rapid fire Code in C
Post by: Anonamous on September 12, 2010, 08:02:24 AM
The most basic way to do it would be to turn an IO port on/off after a certain amount of delay cycles. Here is a simple one for the PIC12F863 using HiTech C.

Code: [Select]

#include <htc.h>

__CONFIG(FCMDIS & IESODIS & BORDIS & UNPROTECT & UNPROTECT & MCLRDIS & PWRTEN & WDTDIS & INTCLK);


void init(){

// CHANGE ANALOG CHANNELS TO DIGITAL I/O
CMCON0 = 0x07; // SET COMPARATOR OFF, CIN and COUT PINS AS I/O
    ANSEL = 0x00; // SET ANALOG INPUTS OFF

TRISIO = 0x00; // SETUP I/O BITS
GPIO = 0x00; // SET I/O BITS LOW

}

void main(){

init();

while(1){

GPIO =0x01;

_delay(50000); // delay 50k cycles
                                      //  50k cycles  seems to work good when using the internal clock

GPIO = 0x00;

_delay(50000);

}

}


And just add a switch between GPIO0 and the Right Trigger.

Im a beginner at this stuff just like you, so if i get corrected, listen to them.

ahh i see, this helps tremendously thank-you
SimplePortal 2.3.5 © 2008-2012, SimplePortal