المرجو من الخبراء ان يحددو لي اين الخطا في هدا الكو د في الميكروك سي
ودالك لقياس الفولط بستعمالpic16f877
1: // LCD module connections
2: sbit LCD_RS at RB2_bit;
3: sbit LCD_EN at RB3_bit;
4: sbit LCD_D4 at RB4_bit;
5: sbit LCD_D5 at RB5_bit;
6: sbit LCD_D6 at RB6_bit;
7: sbit LCD_D7 at RB7_bit;
8:
9: sbit LCD_RS_Direction at TRISB2_bit;
10: sbit LCD_EN_Direction at TRISB3_bit;
11: sbit LCD_D4_Direction at TRISB4_bit;
12: sbit LCD_D5_Direction at TRISB5_bit;
13: sbit LCD_D6_Direction at TRISB6_bit;
14: sbit LCD_D7_Direction at TRISB7_bit;
15: // End LCD module connections
16: int adc;
17: unsigned char ch;
18: long tlong;
19: char *text;
20: char *text1;
21: void main() {
22: LCD_INIT();
23: LCD_CMD(_LCD_CURSOR_OFF); // disable Cursor
24: ADCON1=0b00000001;
25: TRISA=0xFF;
26: TRISB=0x00;
27: TRISC=0x00;
28: text1="Sheimy Voltmater";
29: text="Voltage :";
30: while(1){
31: adc= ADC_Read(2); // A/D conversion. Pin RA2 is an input.
32: LCD_OUT(1,3,text1);
33: Lcd_Out(2,1,text); // Write result in the second line
34: tlong = (long)adc * 5000; // Convert the result in millivolts
35: tlong = tlong / 1023; // 0..1023 -> 0-5000mV
36: ch = tlong / 1000; // Extract volts (thousands of millivolts)
37: // from result
38: Lcd_Chr(2,9,48+ch); // Write result in ASCII format
39: Lcd_Chr_CP('.');
40: ch = (tlong / 100) % 10; // Extract hundreds of millivolts
41: Lcd_Chr_CP(48+ch); // Write result in ASCII format
42: ch = (tlong / 10) % 10; // Extract tens of millivolts
43: Lcd_Chr_CP(48+ch); // Write result in ASCII format
44: ch = tlong % 10; // Extract digits for millivolts
45: Lcd_Chr_CP(48+ch); // Write result in ASCII format
46: Lcd_Chr_CP('V');
47: Delay_ms(1000);
48:
49: }
50:
51: }