还是闪,是不是这种程序里不适合if语句呀,我用除余数的方法如下程序就好了。' u4 P8 ?) r2 a" o) s b3 b
#include <AT89X51.H>" T* r2 s; f' w9 u
unsigned char code led[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
9 k7 d! r' E% A6 ?' h9 |3 hint i=0,j=0,k=1,a=0,js;
4 h, {- C3 f! r* J# Ssbit beep=P2^1;
) m `7 d' F ~- U( H3 x1 }4 esbit P35=P3^5;% s0 l4 Y# Q" p8 }* @
sbit P36=P3^6;
, s. g. [# N& y$ |sbit P37=P3^7;5 `" z6 v, T Q# W5 d9 i
void delay(int aa)2 x' S: Q8 c/ V3 M. ?
{int y,z;! x6 K* p# |! `& ^9 j! J! R8 k
for(y=0;y<aa;y++)2 H2 v- q/ j6 h, b- q
for(z=0;z<60;z++);
) q$ E/ y1 y# C* ], F, [ |}
) t1 m7 }; @) n# x2 L$ G2 o! z4 v3 F t5 t
void main(void) ^& Z% q+ U& u- y2 d1 R
{6 q D$ q' p4 ^# y& j0 z
EA=1;
' ?% H3 _# U( Q) l! WET0=1;
7 A3 l. _! a1 STMOD=0x01;4 a5 G' P" {; [) I" ?
TH0=0xff;8 ?; U6 g* {/ J% E6 r; _5 i0 \" ]
TL0=0xff;
3 f/ k) Y, J2 y+ L7 z, v3 j, {TR0=1;
! K6 `1 M. U1 q, T) D" H3 Z- a; e1 Iwhile(1)
$ B" h! c! n& a7 D) R1 r4 k{
& P2 @( c" D5 v$ u/ X" J! P, `: tfor(i=100;i>=0;i--)$ Y( h4 ]) k& q, {3 U* J
{5 }1 T2 a2 k( k# K; A: `; |; J2 l6 v h
js=i;
1 g0 C7 U- `: n2 n$ F delay(500); } & U8 T9 W Y; h# K8 T
} }
, e. Y; J# X+ r. j
2 W8 i k& o0 f
! {# P9 `( D1 y7 i; o" m# O2 qvoid timer0() interrupt 1
0 u9 K' w0 k, q3 _{ D. x4 p0 b+ g) {& F) B( O# f
P0=led[js/100];
; @6 `; u" D; Y3 UP35=0;
1 F/ E# J8 S- d delay(5);% G, H+ N' S+ u, b
P35=1;
- t9 Y2 l# S* M& ?! _ P0=led[(js-(js/100)*100)/10];0 B: z) ]+ i0 P( }3 P
P36=0;; ~& I8 p& G1 n1 _6 [: W5 o2 u' l
delay(5);+ I# A9 a3 m: |
P36=1;9 y) x9 e* o. N# |/ [) t
P0=led[(js-(js/100)*100)-((js-(js/100)*100)/10)*10];: R4 j8 T7 e/ |0 l' r7 z) q5 |4 H6 ~; a
P37=0;
$ d, X" s! X; \( [- k delay(5);
* L( X, T8 C: a( b4 p$ Z7 q; k P37=1;0 {$ ]+ Y& ]7 t1 ^# `
4 |* o2 d' y( ]5 b+ J! ~* H
TH0=0xB1;
- |! d- |/ c6 \1 g! NTL0=0xE0;, s, B4 [% c+ s, J: l
' V" I0 \$ \. ~0 |6 ?9 J4 O
} |