Fabianr18
New Member
so using a simple if else statement on the code Pommie wrote i can use it to at least do some test runs and have something to present
(the code insert wouldn't work)
(the code insert wouldn't work)
C:
main ()
{
ANSEL=0b000000;
ADCON0bits.ADON=0;
TRISA=0b00010000;
TRISC=0b00000000;
T1CON=0b00000000;
while(1){
unsigned int Timer1Count;
TMR1=0; //clear timer
while(!RA4); //wait for high
T1CONbits.TMR1ON=1; //start timer
while(RA4); //wait low
T1CONbits.TMR1ON=0; //stop timer
Timer1Count=TMR1; //copy timer
// use the timer value here to light LEDs etc.
if(Timer1Count<=220){
PORTC=0;
}
else if(Timer1Count >= 220){
PORTC=0b00000001;}
}
}
Last edited: