还是闪,是不是这种程序里不适合if语句呀,我用除余数的方法如下程序就好了。
1 A0 D( D& T+ P$ N* w, }#include <AT89X51.H>
9 ^7 U- [' a% L/ F& X7 L, S3 M3 |unsigned char code led[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};7 W) e' x4 j4 J% C" u
int i=0,j=0,k=1,a=0,js;6 A2 c( K7 a# w" _, G
sbit beep=P2^1;6 H1 c" q- d; g. @; c& i: O) {+ F
sbit P35=P3^5;
3 F2 n3 S( f! P! M5 x( ?/ S* v' ~sbit P36=P3^6;
0 j3 d% g1 Z* T9 O3 xsbit P37=P3^7;
( |% v8 F- I& X8 g' Jvoid delay(int aa)2 {8 D5 P+ ^8 S# d; G4 y
{int y,z;( D L! W, W" N! x, B
for(y=0;y<aa;y++)
. [/ Q* A% f+ w1 Ffor(z=0;z<60;z++);% i: V! ^" S0 d* X) U1 o
}8 D% ^# M( Z2 t; M8 c
# b2 w: ?) n: B7 `void main(void)
6 m1 |" |+ U! a# {{0 r9 G) v: D+ l# ^$ D+ c
EA=1;
3 k% s% A/ G( w: gET0=1;
0 k n% ]* V6 f& N- A8 J% b* HTMOD=0x01;
6 j' d$ K. |$ M( W4 _/ a& H% ATH0=0xff;
, _3 P4 ~' t! K# t8 hTL0=0xff;
" w! T, k: H( `: U# \TR0=1;
% v$ T: w, I4 R' Z5 Mwhile(1)& A$ ]1 ?: @5 C, H( r
{1 R9 \& A2 S0 N9 x; S. r! l
for(i=100;i>=0;i--)
0 F( U: o/ @& i% k6 x+ r{
0 n8 O3 d' F7 v6 zjs=i;4 V# v, \0 [) c6 S6 `1 f4 z: _
delay(500); } ' v, T6 F5 s' c8 }5 q7 H" ^
} }& [# e3 C4 {# h) C
( \9 v9 N8 N0 w9 M' P
& n9 n# A. i; F& N5 svoid timer0() interrupt 1
4 z- e; }% V6 X# H4 h0 L{) a3 T+ J. W9 s. r
P0=led[js/100];/ W8 _# I/ @1 o
P35=0;: ]$ J/ l* {# {$ `
delay(5);
5 r& d1 U r/ d; @ P35=1;6 o- Y/ k* E7 M; b: V$ E. Y L, V6 f/ z
P0=led[(js-(js/100)*100)/10];
: w9 v3 p' j3 ?4 G1 Q9 rP36=0;
* Q# _, [/ v# n+ b delay(5);
0 _, O' i. P. _2 A. \$ d P36=1;/ z% W7 _; ]' R- }$ ?/ ^- R1 J+ b( D
P0=led[(js-(js/100)*100)-((js-(js/100)*100)/10)*10];, S+ l' W- [, g
P37=0;
9 D- q+ u# S: m+ @1 y7 }# s delay(5);
% s, P, d- u: `5 Z+ [) E/ x- \! G4 m P37=1;
& |0 X9 G- _ p% H4 b) o/ Z, n. a1 ~
TH0=0xB1;
8 d/ x$ M6 F4 |* f( ^- M4 @TL0=0xE0;/ v8 j0 I' K, `7 R/ ~
; s5 D R! D: B/ W5 v
} |