السلام عليكم ورحمة الله وبركاته
عذرا أستاذي على التأخير
بس أنهيت المشروع
يما أنني مبتدأ وجدت شوية صعوبات والحمد لله تمام الحين
أرجووا التقييم
كود:
int LDR_res;
char temp[12];
unsigned int seuil=10;
char ntemp[10];
/*CONFIG_afficheur LCD_LM016L sur le porte B*/
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);
/*preparation l'entrée analog*/
void adc()
{
LDR_res = ADC_Read(2); // Get 10-bit results of AD conversion
LDR_res = (LDR_res *5)/10; // CALCULE l'entrée AOP..
IntToStr(LDR_res,temp); // afficher LDR_res = temp
}
void print()
{
Lcd_Cmd(_LCD_CLEAR); //efface l'ecran au debut
lcd_out(1,1,"Val LDR ") ;
lcd_out(2,1,"Val Seuil ") ;
}
/*pour faire un test sur les résultat*/
void test()
{
if(LDR_res>seuil)
{
PORTC=0b00000001; //cool
}
if(LDR_res<=seuil)
{
PORTC=0x00;
}
}
//////////////////*le programme principale*/////////////////////////////////
void main()
{
TRISA =0b10; // l'entrée de v_LDR
TRISD =0b11; // l'entrée de regulateur v_seuil
TRISC =0x00; // peut étre utiliser ce port pour le clavier
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF); // efface le cursor d'aprés l'affichage
/////////////////////////////////
lcd_out(1,4,"Projet") ; ///
lcd_out(2,3,"fin d'etude") ; ///
delay_ms(1000); ///
Lcd_Cmd(_LCD_CLEAR); ///
lcd_out(1,5," By") ; ///
lcd_out(2,2,"tahar chemori") ;///
delay_ms(500); ///
print(); ///
/////////////////////////////////
do //debut B
{
IntToStr(seuil,ntemp); // couple d'afficheur seuil
lcd_out(2,10,ntemp); //*
delay_ms(200); //*
lcd_out(1,10,temp) ; // pour le LDR_res
delay_ms(200); //**
test();
/* pour adapté la valeur de SEUIL*/
if(portd.f1==0 && seuil>0)
{
seuil--;
delay_ms(200);
}
if(portd.f0==0&&seuil<=100)
{
seuil++;
delay_ms(200);
}
adc(); // appl s/p adc
}
while(1); //fin B
return; // au debut de programme
}
http://www.electvillage.com/upload//...ile=2c23024dfd