السلام عليكم
اين الخطى في هدا الكود
// Positive and Negative Temperature
//Variables
unsigned Temp_P;
unsigned Temp_N;
unsigned Temp_Result;
unsigned ONES;
unsigned TENS;
unsigned HUNDREDS;
#define Enable_ONES PORTB.B6
#define Enable_TENS PORTB.B5
//main
void main()
{
TRISA = 0b00000011; // Configure AN0 (PortA.0) and AN1(port A .1) as an inputs
ADCON1 = 0b10000000; // Set analogue inputs
TRISB = 0; // All PORTB pins as output
PORTB = 0; //Clear PORTB
TRISC=0;
PORTC = 0;
//Endless loop
while (1)
{
//Read the value from channel 0 and channel 1 and store the result.
Temp_P = ADC_Read(0); // Place the conversion into variable
Temp_N = ADC_Read(1); //Place the conversion into variable
//Convert
Temp_P = Temp_P * 0.488 ;
Temp_N = Temp_N * 0.488 ;
//Case 1
if(Temp_P > Temp_N)
{
Temp_Result = Temp_P - Temp_N;
//Diplay_p:Temp_Result consists of
TENS = Temp_Result / 10 ;
ONES = Temp_Result % 10 ;
PORTB=240 | ONES ; // Send ONES data
// Note : 240 = %11110000 , (|) OR to use bit0 to bit3 for 7 segment
//and make bit4 to bit7 high for enable function
//Enable (LE) 4511 ONES digit by low pulse
Enable_ONES=0 ; Delay_MS(1) ; Enable_ONES=1 ; Delay_MS(1) ;
PORTB=240 | TENS ; //Send TENS data
//Enable (LE) 4511 TENS digit by low pulse
Enable_TENS=0 ; Delay_MS(1) ; Enable_TENS=1 ; Delay_MS(1) ;
PORTC = 0B01110011 ; //Letter "P"
}
//Case 2
//if(Temp_P < Temp_N)
else
{
Temp_Result = Temp_N - Temp_P ;
//Diplay_N: Temp_Result consists of
TENS = Temp_Result / 10 ;
ONES = Temp_Result % 10 ;
PORTB=240 | ONES ; //Sens ONES data
// Note : 240 = %11110000 , (|) OR to use bit0 to bit3 for 7 segment
//and make bit4 to bit7 high for enable function
//Enable (LE) 4511 ONES digit by low pulse
Enable_ONES=0 ; Delay_MS(1) ; Enable_ONES=1 ; Delay_MS(1) ;
PORTB=240 | TENS ; //Send TENS data
//Enable (LE) 4511 TENS digit by low pulse
Enable_TENS=0 ; Delay_MS(1) ; Enable_TENS=1 ; Delay_MS(1) ;
PORTC = 0B01000000 ; //g segment
}
}
}