جزيل الشكر لكم إخواني يعني يبدو أن هذه الظاهرة معروفة و لذلك يتم عكس العملية
في عملية الشرط في حال كنت ضغطت الزر يتم فصل الجهد بدل ان يتم توصيل الجهد
على كل انا فعلا اقوم بتعلم المايكرو كنترولر و قد استخدمت
مجموعة اكواد وجدتها و دمجتها في دارة واحدة
منها الlcd و التحكم قراء lm35 و إضافة أو خفط معدل الحرارة المطلوبة بأزرار الضغط
و ايضا أضفت ال max232 لأجل التعامل مع ال serial
ووصلت إلى المرحلة التالي
بعد توصيلها وجدت انه عند ارسال اي حرف من الحاسب لا يحصل شيء
ولي سؤالان لو تكرمتم
الأول الحاسب لدي لا يحوي سيريل استخدم محول من يو اس بي الي ار اس 232
هل في ذلك مشكلة و هل جرب التعامل معها أحد
السؤال التاني : هل أنا ملزم باستخدام max232 ? مع البيك 16f877A
هذا الكود المستخدم لكل ما ذكرت
هل توجد مشاكل لمن يستطيع مراجعة الكود
كود:
int temp_res;
char temp[12];
unsigned int rtemp=30;
char ntemp[10];
unsigned short value;
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
Lcd_Cmd(_LCD_FIRST_ROW);
void adc()
{
temp_res = ADC_Read(0); // Get 10-bit results of AD conversion
temp_res = ((temp_res *5)/10);
IntToStr(temp_res,temp);
}
void print()
{
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,1,"Now temp") ;
lcd_out(2,1,"Ref temp") ;
}
void readserial()
{
if (UART1_Data_Ready())
{
value = UART1_Read();
if (value=='1')
{
rtemp++;
}
else
{
rtemp--;
}
}
}
void test()
{
if(temp_res>rtemp)
{
PORTC=0b00000101; //cool
}
if(temp_res<rtemp)
{
PORTC=0b00001010;//hot
}
if(temp_res==rtemp)
{
PORTC=0x00;
}
}
void main()
{
//TRISA =0b10;
// TRISD =0x00;
TRISC =0x00;
UART1_Init(19200);
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
////////////////////////////////
lcd_out(1,4,"Temperature") ;
lcd_out(2,3,"System Control") ;
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
print();
do
{
IntToStr(rtemp,ntemp);
lcd_out(2,10,ntemp);
delay_ms(200);
lcd_out(1,10,temp) ;
delay_ms(200);
test();
if(portd.f1==0)
{
rtemp--;
}
if(portd.f0==0)
{
rtemp++;
UART1_Write('y');
}
adc();
readserial();
}
while(1);
return;
}