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
-
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.
-
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
-
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.
-
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.
#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.
-
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
-
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.
#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