Please help support the site by donating at the link below.https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8ZRU34U47BESW
# pragma chip PIC12F683/ / pin name# define rttriger GPIO.0# define lttriger GPIO.1# define sync GPIO.3# define LED GPIO.2void Init (){ // Set Frequency 8mhz OSCCON = 0b01110001 ; // Configure GPIO Port ANSEL = 0b00000011; // Configure pins GP0 , GP1 as ANALOG Trisio = 0b00001011; // GP0 , GP1 GP3 are input , rest is output GPIO = 0xFF; // Set all pins to output high (0x00 = low) // Set Comparator CMCON0 = 7; // Comparator is turned OFF }void main (){ INIT(); while(1) { adc = ADC_Read(0); // Get 10-bit results of AD conversion for GPIO0 if(adc == 0) { //Trigger is not pulled ANS0_bit = 1; if ( adc > 409) { //Trigger is pulled ANS0_bit = 0; RT = 0x00; // LOW RT ? sps; Delay_Cyc(adc); } } }; // End of run loop forever} //End of main
/*******************************************************************************PIC12F683 @ 8MHzCode for Blinking an LED on GP2 if Sync Button on GP3 is pressedAcidMods*******************************************************************************/#define LED GP2_bit#define SY GP3_bitvoid INIT(){OSCCON = 0b01110111; // Set 8mhz FrequencyCMCON0 = 7; // Comparator offANSEL = 0; // Analog OffTRISIO0_bit = 0; //TRISIO1_bit = 0; //TRISIO2_bit = 0; // LED (set to Input or it will interfere with the controller being able to use it)TRISIO3_bit = 1; // SYNC ButtonTRISIO4_bit = 1; //TRISIO5_bit = 1; //}void main() { // Start of Main INIT(); // Initialize the PICwhile (1){ // Start of Run Forever Loop while (SY == 0){ // While the SYNC button is pressed TRISIO2_bit = 0; // Set LED pin to Output (must set back to an Input when finished with the LED) LED = 1; // Turn LED on delay_ms(300); // Time LED is on, 300ms LED = 0; // Turn LED off delay_ms(50); // Time LED is off, 50ms } TRISIO2_bit = 1; // Turns LED off and keeps the pin TRIS so the controller can use the LED } // End of Run Forever Loop} // End of Main
/******************************************************************************* PIC12F683 @ 8MHz Code for simple rapid fire for xbox 360 for [url=https://www.acidmods.com]www.acidmods.com[/url]*******************************************************************************/void main(){// Start of Main int mod = 0, i, sps[3] = {0 , 0, 0}; INIT(); // Initialize the PICwhile (1){ if (SYNC == 0) { //if the SYNC button is pressed mod++; if(mod > 3) mode = 1; for(i = 0; i < mod; i++) { TRISIO2_bit = 0;// Set LED pin to Output LED = 1;// Turn LED on delay_ms(300);// Time LED is on, 300ms LED = 0; // Turn LED off delay_ms(300); // Time LED is off, 50ms } } switch(mod) { case 1: TRISIO5_bit = 0; //set RT pin to output if(rt == 1) { sps[0] = (1000/10)/2; sps[0]; } break; case 2: TRISIO4_bit = 0; //set LT pin to output TRISIO5_bit = 0; // set RT pin to output if(rt == 1 || lt == 1) { sps[1] = (1000/18)/2; sps[1]; } break; case 3: break; } TRISIO2_bit = 1; TRISIO4_bit = 1; TRISIO5_bit = 1; } }
/*******************************************************************************PIC12F683 @ 8MHzCode for simple rapid fire for xbox 360AcidMods*******************************************************************************/#define LED GP2_bit#define SYNC GP3_bit#define rt GP5_bit#define lt GP4_bitvoid INIT(){ OSSCCON = 0b01110001; //set int osc to 8MHz CMCON0 = 7; // Comparator off CMCON1 = 0; ANSEL = 0b00101000; // Analog On ? TRISIO0_bit = 0; // TRISIO1_bit = 0; // TRISIO2_bit = 0; // LED (set to Input or it will interfere with the controller being able to use it) TRISIO3_bit = 1; // SYNC Button TRISIO4_bit = 1; // Trigger LT TRISIO5_bit = 1; // Trigger RT }void main(){// Start of Main int mode = 0, i, sps = (1000/10)/2; unsigned int adcValue; INIT(); // Initialize the PIC while (1){ // Start of Run Forever Loop if (SYNC == 0) {//if the SYNC button is pressed mode = 1; for(i = 0; i < mode; i++) { TRISIO2_bit = 0;// Set LED pin to Output (must set back to an Input when finished with the LED) LED = 1;// Turn LED on delay_ms(300);// Time LED is on, 300ms LED = 0; // Turn LED off delay_ms(300); // Time LED is off, 300ms } } if(mode) { adcValue = ADC_Read(5); //read analog value pin 5 (RT) ?? if(adcValue > 0) { Delay_Cyc(adcValue); //..... ??? TRISIO5_bit = 0; sps; } } TRISIO2_bit = 1;// Turns LED off and keeps the pin TRIS so the controller can use the LED TRISIO5_bit = 1; } // End of Run Forever Loop } // End of Main
/*******************************************************************************PIC12F683 @ 8MHzsimple rapid fire for xbox 360AcidMods*******************************************************************************/#define LED GP2_bit#define SYNC GP3_bit#define rt GP5_bit#define lt GP4_bitvoid INIT(){ OSCCON = 0b01110001; // Set 8mhz Frequency // Configure GPIO Port ANSEL = 0b00110000; // Configure pins GP5, GP4 as ANALOG TRISIO = 0b00111000; // GP5, GP4 GP3 are input, rest is output // INIT ADC ADCON0 = 0b10110110; // right justified??? ADON_bit = 1; //turn on adc convertion Delay_ms(1000); //necessary?? GO_DONE_bit = 1; //start conversion // Configure Comparator CMCON0 = 7; }void main(){// Start of Main int i, sps = (1000/10)/2; unsigned int adc; INIT(); // Initialize the PIC while (1){ // Start of Run Forever Loop // adc = adc_read(5); //get adc value // (1024/1.2)*3; if(rt == 0) { while (GO_DONE) continue; //???polling for conversion completion if (adc_read (5) >= 408) // input voltage >= 1.2V { rt = 0; Delay_Cyc(sps); } else rt = 1; } } // End of Run Forever Loop} // End of Main
int whatever;whatever = ADC_Read(5); // Then whatever is the Analog value on that pin. It's already setup and does it all for you to return the 10bit value.if (whatever >= value_you _want _it_to_do_something) { then do something }
unsigned int temp_res;void main() { ANSEL = 0x04; // Configure AN2 pin as analog ANSELH = 0; // Configure other AN pins as digital I/O C1ON_bit = 0; // Disable comparators C2ON_bit = 0; TRISA = 0xFF; // PORTA is input TRISC = 0; // PORTC is output TRISB = 0; // PORTB is output do { temp_res = ADC_Read(2); // Get 10-bit results of AD conversion PORTB = temp_res; // Send lower 8 bits to PORTB PORTC = temp_res >> 8; // Send 2 most significant bits to RC1, RC0 } while(1);}
void Init (){ OSCCON = 0b01110001 / / Set Frequency 8mhz / / Configure GPIO Port ANSEL = 0b00000011 / / Configure pins GP0 , GP1 as ANALOG Trisio = 0b00001011 / / GP0 , GP1 GP3 are input , rest is output / / GPIO = 0xff / / Set all pins to output high (0x00 = low) / / Set Comparator CMCON0 = 7 / / Comparator is turned OFF } void main() { int sps = (1000/10)/2; unsigned int adc; do { adc = ADC_Read(0); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 409) { //Trigger is pulled Wait X //Force release and Wait X } } while(1);}
/*******************************************************************************PIC12F683 @ 8MHzCode for simple rapid fire for xbox 360AcidMods*******************************************************************************/#define RT GP0_bit#define LT GP1_bit#define LED GP2_bit#define SYNC GP3_bitvoid Init (){ // Set Frequency 8mhz OSCCON = 0b01110001 ; // Configure GPIO Port ANSEL = 0b00000011; // Configure pins GP0 , GP1 as ANALOG Trisio = 0b00001011; // GP0 , GP1 GP3 are input , rest is output GPIO = 0xFF; // Set all pins to output high (0x00 = low) // Set Comparator CMCON0 = 7; // Comparator is turned OFF }void main() { int sps = (1000/10)/2; unsigned int adc; Init(); while(1) { adc = ADC_Read(0); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 409) { //Trigger is pulled TRISIO0_bit = 0; RT = 0x00; // LOW RT ? sps; Delay_Cyc(adc); } else { //Trigger is not pulled TRISIO0_bit = 1; } }; // End of run loop forever} //End of main
if ( adc > 409){//Trigger is pulledDelay_ms(sps); //Continue to allow trigger to be pulled//Now we have to force trigger releaseTRISIO0_bit = 0;Delay_ms(sps);//We are done firing one shot. We need to set TRISIO0 back to inputTRISIO0_bit = 1;}
/*******************************************************************************PIC12F683 @ 8MHzCode for simple rapid fire for xbox 360AcidMods VDD-1| |8-VSSGP5/T1CKI-2| |7-GP0/ANS0 GP4/AN3-3| |6-GP1/ANS1 GP3/MCLR-4| |5-GP2/ANS2*******************************************************************************/#define RT GP1_bit#define LT GP0_bit#define LED GP2_bit#define SYNC GP3_bitvoid Init (){ // Set Frequency 8mhz OSCCON = 0b01110001 ; // Configure GPIO Port ANSEL = 0b00000011; // Configure pins GP0 , GP1 as ANALOG Trisio = 0b00001011; // GP0 , GP1 GP3 are input , rest is output GPIO = 0xFF; // Set all pins to output high (0x00 = low) // Set Comparator CMCON0 = 7; // Comparator is turned OFF PWM1_Init(19530); //Frequencies datasheet fosc8Mhz = 19.61kHz }void main() { int i = 0, sps = (1000/10)/2; unsigned int adc; Init(); while(1) { if (SYNC == 0) { // if the SYNC button is pressed TRISIO2_bit = 0; // Set LED pin to Output (must set back to an Input when finished with the LED) LED = 1; // Turn LED on delay_ms(300); // Time LED is on, 300ms LED = 0; // Turn LED off delay_ms(300); // Time LED is off, 300ms } adc = ADC_Read(1); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 200 ) { //Trigger is pulled //delay_ms(sps); //Continue to allow trigger to be pulled //Now we have to force trigger release TRISIO1_bit = 0; PWM1_Set_Duty(63); sps; //We are done firing one shot. We need to set TRISIO0 back to input TRISIO1_bit = 1; } else TRISIO1_bit = 1; Delay_ms(25); TRISIO2_bit = 1; }; // End of run loop forever} //End of main
thank you for all these explanations and assistancenew code:Code: [Select]void main() { int i = 0, sps = (1000/10)/2; unsigned int adc; Init(); while(1) { adc = ADC_Read(1); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 200 ) { //Trigger is pulled sps; //Continue to allow trigger to be pulled //Now we have to force trigger release TRISIO1_bit = 0; delay_ms(25); sps; //We are done firing one shot. We need to set TRISIO0 back to input TRISIO1_bit = 1; } else TRISIO1_bit = 1; Delay_ms(25); }; // End of run loop forever} //End of main
void main() { int i = 0, sps = (1000/10)/2; unsigned int adc; Init(); while(1) { adc = ADC_Read(1); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 200 ) { //Trigger is pulled sps; //Continue to allow trigger to be pulled //Now we have to force trigger release TRISIO1_bit = 0; delay_ms(25); sps; //We are done firing one shot. We need to set TRISIO0 back to input TRISIO1_bit = 1; } else TRISIO1_bit = 1; Delay_ms(25); }; // End of run loop forever} //End of main
Did I use PWM? for example you will be there detectable, COD WAW?
You make me want to cry.
void main() { int i = 0, sps = (1000/10)/2; unsigned int adc; Init(); while(1) { adc = ADC_Read(1); // Get 10-bit results of AD conversion for GPIO0 if ( adc > 200 ) { //Trigger is pulled Delay_ms(sps); //Continue to allow trigger to be pulled //Now we have to force trigger release TRISIO1_bit = 0; Delay_ms(sps); //We are done firing one shot. We need to set TRISIO1 back to input TRISIO1_bit = 1; } }; // End of run loop forever} //End of main