Ví dụ đơn giản như thế này:
Mà sao không được các bác nhỉ kqua nó ra thế này các bác ạ.
Ý em là muốn cho 1 con led sáng số 2, 1 con số 3 là nó lại ra như thế này, nghĩ mãi mà không biết sai chỗ nào nữa! Các bác giúp em với!
PHP Code:
#include <AT89X52.H>
#define Date1 P2_0
#define Date2 P2_1
#define Mth1 P2_2
#define Mth2 P2_3
#define Year1 P2_4
#define Year2 P2_5
#define Year3 P2_6
#define Year4 P2_7
#define Thu P1_4
#define Hour1 P3_3
#define Hour2 P3_4
#define Min1 P3_5
#define Min2 P3_6
#define Sec1 P3_7
#define Sec2 P1_3
#define Display_Date_Chuc {\
Date1 = 0;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Date_DV {\
Date1 = 1;\
Date2 = 0;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Month_Chuc {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 0;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Month_DV {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 0;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Year_Nghin {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 0;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Year_Tram {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 0;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Year_Chuc {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 0;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Year_DV {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 0;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Thu {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 0;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Hour_Chuc {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 0;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Hour_DV {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 0;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Min_Chuc {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 0;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Min_DV {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 0;\
Sec1 = 1;\
Sec2 = 1;\
}
#define Display_Sec_Chuc {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 0;\
Sec2 = 1;\
}
#define Display_Sec_DV {\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 0;\
}
#define Khoi_tao{\
Date1 = 1;\
Date2 = 1;\
Mth1 = 1;\
Mth2 = 1;\
Year1 = 1;\
Year2 = 1;\
Year3 = 1;\
Year4 = 1;\
Thu = 1;\
Hour1 = 1;\
Hour2 = 1;\
Min1 = 1;\
Min2 = 1;\
Sec1 = 1;\
Sec2 = 1;\
}
unsigned char dem=0;
unsigned char led7_data[10] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90 };
void Timer_setup(void)
{
TMOD=0x11;
TH0=0xF4; TL0=0x48;
ET1=0; ET0=1; EA=1;
TF0=0; TF1=0; TR0=1; TR1=0;
}
void T0_ISR() interrupt 1
{
TR0=0;TF0=0;TH0=0xF4; TL0=0x48;
dem++;
switch(dem)
{
case 1:
P0=0xff;
Display_Hour_DV;
P0=led7_data[2];
break;
case 2:
P0=0xff;
Display_Hour_Chuc;
P0=led7_data[3];
dem=0;
break;
}
TR0=1;
}
void main(void)
{
Timer_setup();
}
Ý em là muốn cho 1 con led sáng số 2, 1 con số 3 là nó lại ra như thế này, nghĩ mãi mà không biết sai chỗ nào nữa! Các bác giúp em với!
Comment