بسم الله الرحمن الرحيم
اليك اخى العزيز مثال و الله الموفق ,
كود:
// LCD module connections
sbit LCD_RS at PORTB2_bit;
sbit LCD_EN at PORTB3_bit;
sbit LCD_D4 at PORTB4_bit;
sbit LCD_D5 at PORTB5_bit;
sbit LCD_D6 at PORTB6_bit;
sbit LCD_D7 at PORTB7_bit;
sbit LCD_RS_Direction at DDB2_bit;
sbit LCD_EN_Direction at DDB3_bit;
sbit LCD_D4_Direction at DDB4_bit;
sbit LCD_D5_Direction at DDB5_bit;
sbit LCD_D6_Direction at DDB6_bit;
sbit LCD_D7_Direction at DDB7_bit;
// End LCD module connections
float analog_val;
int analog_val_integer;
short txt[2];
void main() {
DDRB=0XFF;
Lcd_Init();
Lcd_Cmd(_lcd_cursor_off);
Lcd_Out(1,1,"TEMPERATURE" );
while(1){
analog_val = ADC_Read(0) ; // READING INPUT VOLTAGE
analog_val = analog_val * 5000/1023.0 ;// CONVERT INPUT TO ANALOG VAL IN MILLI VOLT
analog_val = analog_val / 10; // DIVIDE BY 10 FOR LM35 DATASHEET
analog_val_integer = analog_val;// TAKE INTEGER VALUE OF TEMPERATURE
wordToStr(analog_val_integer/10, txt);
Lcd_Out(2,1,ltrim(txt));
wordToStr(analog_val_integer%10, txt);
Lcd_Out(2,2,Ltrim(txt));
}
}
البروتيوس :

اللهم احفظ اقصانا و امتنا
|
السلام عليكم اخي في الله
اشكرك اخي علي سرعة الرد واسال ما طلبت منك
والكود المرسل لي يعمل بكفائة عالية ماشاء الله
ولكني اسمح لي بعدة اسئلة لا افهمها
1- لماذا لم نكتب ADC_Init() :
2- المترجم لا يريد جعل باقي البورت A دجتال مثلا DDRA.f3=1;
3-ما هي الاعدادت الصحية التي يجب ان افعلها علي برنامج البروتس