في ميكرو سى و عند إنشاء مشروع جديد يجب ان تسير مع الويزارد او الخطوات بدقة و فيها تحدد مكان واسم المشروع ورقم الميكرو وتردد الكريستال وخارجي ام داخلي
و أيضاً تضم كل المكتبات كاملة للمشروع فهذا يضم تعريفات هذه المكتبات للمشروع
ثم تقرأ ملف المساعدة لتعرف التهيئة الضرورية للمكتبة
فمثلاً ستحتاج هنا
Lcd_init
وكان سيتعرف منها علي المكتبة وهل تستخدم 4 أم 8 بت و أين هذه الأطراف الخ
أيضاً بعض الملفات مكتوبة لميكرو معين فلو استخدمت رقم آخر سيكون تحديد التهيئة مختلف بحسب الميكرو المستخدم
|
شكرا لك اخي الكريم على الرد ولكن انا اعرف ولقد قمت بكل الاجراءات المطلوبة وسارفق لك البرنامج واذا امكن ان تراجعه لي
وجزاك الله خيرا عني
كود:
sbit LCD_RS at Rd4_bit;
sbit LCD_EN at Rd5_bit;
sbit LCD_D7 at Rd3_bit;
sbit LCD_D6 at Rd2_bit;
sbit LCD_D5 at Rd1_bit;
sbit LCD_D4 at Rd0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISd4_bit;
sbit LCD_EN_Direction at TRISd5_bit;
sbit LCD_D7_Direction at TRISd3_bit;
sbit LCD_D6_Direction at TRISd2_bit;
sbit LCD_D5_Direction at TRISd1_bit;
sbit LCD_D4_Direction at TRISd0_bit;
//=======================================================================
unsigned int adc_value;
float tempc;
float _tempc=0;
unsigned short ccmp_value;
char tempc_txt[15];
unsigned short cnt;
char cnt_txt[4];
bit temp_flag;
bit swtch1;
bit swtch2;
//=======================================================================
void conter(){
if(swtch1==1){
cnt++;
if(cnt>148)cnt=150;
EEPROM_Write(0,cnt);
delay_ms(300);
}
if(swtch2==1){
cnt--;
if(cnt<1)cnt=1;
EEPROM_Write(0,cnt);
delay_ms(300);
}
shorttostr(cnt,cnt_txt) ;
Lcd_Out(1, 1, "Temp=");
Lcd_Out_Cp(cnt_txt);
}
//===============================================
void control(){
if(ccmp_value==cnt){
portb.b6=0;
portb.b7=0;
Lcd_Out(2, 1, "Normall");
}
else if(ccmp_value>cnt){
portb.b6=1;
portb.b7=0;
Lcd_Out(2, 1, " ");
Lcd_Out(2, 1, "Hot");
}
else{
portb.b6=0;
portb.b7=1;
Lcd_Out(2, 1, " ");
Lcd_Out(2, 1, "cold");
}
}
//=================================================================
void _init(){
ADC_Init();
adcon1=0b00000101;
trisb.b0=1;
trisb.b1=1;
trisb.b6=0;portb.b6=0;
trisb.b7=0;portb.b7=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 3, "Hattching");
Lcd_Out(2, 3, "Egg");
}
//===================================================
void get_adc(){
adc_value=ADC_Read(0);
tempc= adc_value *1.5 ;
tempc=tempc/1024;
tempc=tempc*100;
if(tempc!=_tempc) {
temp_flag=1;
_tempc=tempc ;
ccmp_value=tempc;
floattostr(tempc,tempc_txt);
Lcd_Out(1, 1,"Temp=");
Lcd_Out_Cp(tempc_txt);
if(tempc<1){Lcd_Out_Cp(" ");}
Lcd_Chr_Cp('c');
}
}
//===================================================
void main() {
_init();
cnt = EEPROM_Read(0);
conter();
do{
get_adc();
if(portb.b0==1){swtch1=1;conter();}
if(portb.b1==1){swtch2=1;conter();}
if(temp_flag==1||swtch1==1|| swtch2=1){
}
temp_flag=0;
swtch1=0;
swtch2=0;
}
while(1);
}