But I don’t rely know how to use timer0/1,, I just assign the signal as variable then display it on lcd,,
I think that might be the problem.
Somebody can help me with reading signal, how to setup timer0/1,, and how to use it...
Tq..
- CODE: SELECT_ALL_CODE
#include <htc.h>
#include <stdio.h>
#include "lcd.c"
#define _XTAL_FREQ 20000000
__CONFIG(0X3f32); //configuration bits@ microcontroller
void pulse ( void ) ;
void __delay_sec(int x); // function delcaration
//*********************************************
void main(void)
{ //start main
int h; //variable
TRISB=0b00000001;
PORTB=0b00000000;
lcd_init();
h=RB0;
lcd_clear();
while(1){ //start endless loop
pulse();
h=RB0 ;
printf(" ULTRASONIC %d" ,h);
__delay_sec(10);
lcd_clear();
h=0;
}
} //end of while
//*********************************************
void pulse ( void )
{ RB1=0;
__delay_us(2);
RB1=1;
__delay_us(10);
RB1=0;
}
void __delay_sec(int x) // function delcaration
{
int j;
int k;
for(j=0;j<x;j++)
for(k=0;k<5;k++)
__delay_ms(20);
}