Raff
Newbie level 4
Hello. Im using PIC16F877. I have tried to program Sharp Distance sensor and try to display the value in USART terminal by using micro C pro. There have 3 pin, RA1, GND and Vin. There have a problem because the value were not display in USART terminal.I have set the serial connection to COM3. This is my C Program.
int Adc;
char txt [6];
void Read_Adc()
{
ADCON0=0b01001001;
ADCON0.GO=1;
while(ADCON0.GO);
Adc=(ADRESH*4)+(ADRESL/64);
}
void main()
{
Delay_ms(1000);
UART1_Init(9600);
Delay_ms(1000);
UART1_Write_Text("raw data:");
UART1_Write(10);
UART1_Write(13);
while(1)
{
Read_Adc();
WordToStr(Adc,txt);
UART1_Write_Text(txt);
}
}
Thanks a lot.
int Adc;
char txt [6];
void Read_Adc()
{
ADCON0=0b01001001;
ADCON0.GO=1;
while(ADCON0.GO);
Adc=(ADRESH*4)+(ADRESL/64);
}
void main()
{
Delay_ms(1000);
UART1_Init(9600);
Delay_ms(1000);
UART1_Write_Text("raw data:");
UART1_Write(10);
UART1_Write(13);
while(1)
{
Read_Adc();
WordToStr(Adc,txt);
UART1_Write_Text(txt);
}
}
Thanks a lot.