Click here to Skip to main content
16,023,224 members

Comments by shafiq2eng (Top 1 by date)

shafiq2eng 31-Jan-14 12:16pm View    
i mad Voltage meter Using PIC MikroC successfully and now i want to send this analogue data on serial port to show voltage on Visual Studio Form, Pleas help me....
My codes are below

sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC2_bit;
sbit LCD_D5 at RC3_bit;
sbit LCD_D6 at RC4_bit;
sbit LCD_D7 at RC5_bit;

sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC4_bit;
sbit LCD_D7_Direction at TRISC5_bit;
//************************************************//

void main() {
char ch;
int adc_read_val;
long tlong;
ANSEL = 0b00000001; // Configure AN pins as digital I/O
/*ADCON0= 0b10000011;
ADCON1=0b00000000;*/
vcfg_bit=0;
// CM0_bit=0;CM1_bit=0;CM2_bit=0;
TRISA=1;
PORTA=0;
Lcd_Init();
Lcd_Cmd(_Lcd_clear);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,"VOLT METER");
Delay_ms(1000);
//************************************************//
while(1){//start of while
adc_read_val=adc_read(0);
tlong=(long)adc_read_val*5000;
tlong=tlong/1023;
ch=tlong/1000;
Lcd_Chr(2,3,ch+48);
lcd_chr_cp('.');
ch=(tlong/100)%10;
lcd_chr_cp(48+ch);
ch=(tlong/10)%10;
lcd_chr_cp(48+ch);
ch=tlong%10;
lcd_chr_cp(48+ch);
lcd_chr_cp('V');
}//end of while
}