لقد ثم اضافة شرطان لكي تعمل المروحة
كود:
sbit LCD_RS at Rb0_bit;
sbit LCD_EN at Rb1_bit;
sbit LCD_D7 at Rb7_bit;
sbit LCD_D6 at Rb6_bit;
sbit LCD_D5 at Rb5_bit;
sbit LCD_D4 at Rb4_bit;
// Pin direction
sbit LCD_RS_Direction at TRISb0_bit;
sbit LCD_EN_Direction at TRISb1_bit;
sbit LCD_D7_Direction at TRISb7_bit;
sbit LCD_D6_Direction at TRISb6_bit;
sbit LCD_D5_Direction at TRISb5_bit;
sbit LCD_D4_Direction at TRISb4_bit;
unsigned char text0[4] ;
unsigned char text1[4] ;
char uart_rd;
int temp0 = 0;
//Programme principal :azzab //
void main ()
{
trisc.f0=0;
portc.f0=0;
Uart1_Init (9600);
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "Temperature");
do {
temp0 = Adc_Read(0); // Lu canal AN0 et enregistrez la valeur dans la variable temp0
temp0 =temp0/2.05;// Convertir de valeur à la température
temp0= (temp0-271.5 );
ByteToStr(temp0, text0);// Convertit la chaîne TEMP.
Lcd_Out(2, 1, text0);
Lcd_Chr_cp('C');
UART1_Write_Text(text0); // Envoyé à l'uart
UART1_Write_Text(" C");
Uart1_Write('\r'); // OR 13 : Retour chariot
delay_ms(500);
if(temp0 >=40) portc.f0=1;
if(temp0 <=40) portc.f0=0;
}
while (1);
}