还是闪,是不是这种程序里不适合if语句呀,我用除余数的方法如下程序就好了。
: j2 {# D2 y& w5 Z! {! w3 O#include <AT89X51.H>
0 Z( X! G& a# L$ W: ~unsigned char code led[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
8 T& G* k ^$ Bint i=0,j=0,k=1,a=0,js;
& r& p6 W3 x2 ^1 H. Dsbit beep=P2^1;: s6 g5 i$ n, ~# O
sbit P35=P3^5;
) T9 z7 C: S) }/ k! T+ _* _2 Qsbit P36=P3^6;
7 {8 @4 v+ O$ o7 Zsbit P37=P3^7;* Z" f# [& X) o
void delay(int aa); l3 `! z& V2 t, l- O
{int y,z;
1 M9 r: U/ r1 I3 e+ h- k# d1 gfor(y=0;y<aa;y++)7 `' d, n( f( Z: S
for(z=0;z<60;z++);
) `9 q' y1 c/ S5 C( {}# \ T9 w9 N+ ~2 ]+ K# U
" E1 B; R! W& ~; s; I
void main(void)2 i6 J2 M4 d8 t; ^, Z; d$ H0 M
{5 Q2 ]" Q3 H. ~
EA=1;3 u. [2 r6 @, s; ` D4 }
ET0=1; J3 O1 n9 [1 G6 C$ }. _
TMOD=0x01;
4 s- J& Q4 ?, \TH0=0xff;2 q% x. v8 ]; J9 X! u9 u% c C
TL0=0xff;
! b+ {; P- t1 R$ I/ }! GTR0=1;
2 E( ^, v: k8 q4 N+ ]- gwhile(1)
. J7 W; [# m- L. q1 ~# o0 a. N3 q{9 f0 p G+ r6 E! r- @2 b
for(i=100;i>=0;i--)# V" n# \! ~( |9 g! e5 G0 v
{+ E$ {. [, w( }+ A2 I* r
js=i;
/ Z% }/ [" z3 Q; ` delay(500); } 0 K- I3 | ~# |% m" i& g _+ I* f& I
} }
0 c; N' ^1 z+ I* b* u
( t4 y1 a( {! H+ ~5 {! {) i8 G) A/ j8 u) `6 V5 E
void timer0() interrupt 1
3 b8 E+ P4 o* H" J) d{ M% i. }4 c1 l3 k' U
P0=led[js/100];
" {+ n: d8 \" d& \2 s/ ?. [P35=0;
. I# c( ]0 ^& N5 }2 A4 f; U; | delay(5);
/ Y. b! h' x9 M4 k) @# L7 n6 D P35=1;% }. s2 D) w" M l
P0=led[(js-(js/100)*100)/10];
! O, b/ i. b. x p0 R1 @/ o" SP36=0;- E5 _) @) _' w2 U& C
delay(5);
3 f6 t! j* s: L7 E& a P36=1;
( ~( v3 U( v; L P0=led[(js-(js/100)*100)-((js-(js/100)*100)/10)*10];" n. D$ i/ T3 G6 b, D- `
P37=0;' o A$ Z2 b3 r* x" S
delay(5);& ?- q3 e$ Y5 S$ [) Y% i: H% P6 ^
P37=1;" W$ r/ J W+ o9 u! \+ t
+ x1 G! L. C, P P- ]( GTH0=0xB1;
9 _* S V5 ?; v) nTL0=0xE0;" E$ e) f! ` g \
8 E6 H8 b* r8 Z4 z9 X, M} |