Microcontroller › PIC › How to Connect a reed sensor to a PIC24 or any PIC? › Hi,Make your code to wait
November 22, 2013 at 1:14 pm
#10638
AJISH ALFRED
Participant
Hi,
Make your code to wait till the switch open like the following;
while(1)
{
while (TRISAbits.TRISA0 == 0); //wait till Switch on reed 1 opens
TMR1 = 0;
PR1 = 0;
while(TRISAbits.TRISA1 == 0) //wait till Switch on reed 2 opens
PR1 = time1;
while(TRISAbits.TRISA1 == 0) //wait till Switch on reed 2 opens
TMR2 = 0;
PR2 = 0;
while(TRISBbits.TRISBO == 0); //wait till Switch on reed 3 Opens
PR2 = time2;
}
I hope this may work!!