اخوتي تفذت مشروع الاخ احمد معاطي الله يبارك فيه وفيكم
موجود في المنتدى مقياس حرارة وعمل طبيعي ولكن مشكلة
الرقم 6 و9 تظهر كما مبين في الصورة ( اي غير كاملة)ارجو تصحيح الكود اذا
كان المشكلة في الكود شكرا
[IMG]

[/IMG]
وهذا الكـــــــــــــــــــــــــــــــــــــــــــود
كود:
unsigned short digit_no, digit10, digit1, digit, i; x; Y;
unsigned int temp_res;
unsigned short mask(unsigned short num) {
switch (num) {
case 0 : return 0xC0;
case 1 : return 0xF9;
case 2 : return 0xA4;
case 3 : return 0xB0;
case 4 : return 0x99;
case 5 : return 0x92;
case 6 : return 0x83;
case 7 : return 0xF8;
case 8 : return 0x80;
case 9 : return 0x98;
}
}
void interrupt() {
if (digit_no==0) {
PORTC = 0; // Turn off all 7seg displays
PORTD = digit1; // send mask for ones digit to PORTD
PORTC = 1; // turn on 1st 7 seg., turn off 2nd
digit_no =1;
} else {
PORTC = 0; // Turn off all 7seg displays
PORTD = digit10; // send mask for tens digit to PORTD
PORTC = 2; // turn on 2nd 7 seg., turn off 1st
digit_no = 0;
}
TMR0 = 0; // clear TMRO
INTCON = 0x20; // clear T0IF and set T0IE
}
void main() { char read ;
OPTION_REG = 0x80; // Timer0 settings
TMR0 = 0;
INTCON = 0xA0; // Disable PEIE,INTE,RBIE,T0IE
PORTC = 0; // clear PORTc (make sure both displays are off)
TRISC = 0b11111100; // designate PORTc pins as output
PORTD = 0; // clear PORTD (make sure LEDs are off)
TRISD = 0; // designate PORTD pins as output
TRISA = 0b00000000; //PORTA I/POT
TRISB = 0; //PORTB O/POT
PORTB = 0;
maty:
while(1)
{ if(i<=x){PORTB=0b00000001;} // TEST
if(i>=x){PORTB=0b00000010;} // TEST
temp_res = ADC_Read(2);
temp_res = (temp_res *5)/10;
i = temp_res;
if(i<=99)
if(i>=0)
if( portc.f5==1) // TEMP
{
digit = i % 10u;
digit1 = mask(digit); // prepare ones digit
digit = (char)(i / 10u) % 10u;
digit10 = mask(digit); // prepare tens digit
Delay_ms(200); }
if( portc.f5==0) { // HETR1
if(portc.f6==0) {
(x);
delay_ms(50);
x++; }
if(portc.f7==0) {
(x);
delay_ms(50);
x--; }
if(x<=99)
if(x>=0)
{
digit = x % 10u;
digit1 = mask(digit); // prepare ones digit
digit = (char)(x / 10u) % 10u;
digit10 = mask(digit); // prepare tens digit
Delay_ms(200); }
}
}
goto maty
}