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
void main(void){ // initialize the device SYSTEM_Initialize(); ADC_Initialize(); ADC_SelectChannel(RT); while (1) { ADC_StartConversion(); while (ADC_GetConversion(RT) < 300) { __delay_us(480); // wait for voltage to settle } if (ADC_GetConversion(RT) < 300) { LATA = 0; //clear A pins LATA5 = 0; // led set high TRISA5 = 0; // make output __delay_ms(500); TRISA5 = 1; // make input __delay_ms(500); } }}
For some reason its working the opposite way round
#define LED LATB6_bit // LED for feedbackunsigned int RT;unsigned int RT_ON = 10;unsigned int RT_PULLED = 300;void main(){ INIT(); // Setup the PIC config bits, OSC, TRIS, etc, etc, (not shown here since that's PIC dependent) while(1){ while(ADC1_Read(9) <= RT_ON) // While RT is turned off do nothing. {} // When the RT is turning on and the voltage rises it will jump out of this while loop delay_us(100); // delay for the RT voltage to settle RT = ADC1_Read(9); // Read the RT line again here to see where it actually is if(RT <= RT_PULLED) // If RT is pulled the amount you want or more.. { LED = ~LED; delay_ms(200); // .. then Blink the LED.. }else // Else If RT is not pulled the amount you want.. { delay_ms(2); // .. then wait 2ms for the pulse to finish and start all over LED = 1; // Make sure LED is off if RT is released } }}