|
|
马上注册,结识高手,享用更多资源,轻松玩转三维网社区。
您需要 登录 才可以下载或查看,没有帐号?注册
x
目的是控制几个数码管依次点亮 第一个显示1,第二个显示2,第三个显示3.。。。。。
0 c+ @, I; s& Y) `, h Y. l% r" _% S8 J0 M" z
#include<reg52.h>
H. D7 ?) @+ W% T+ s#include<intrins.h>0 x: S" M3 D$ I7 p% O5 H- y
#define uint unsigned int( ?+ f: l# g5 B& Z5 t
#define uchar unsigned char
% J/ L4 Q) L- F9 u& P' L. I2 osbit wela=P2^7;------------------------位控端口,接锁存, o ]8 B2 @! R. \
sbit dula=P2^6; -----------------------段控端口,接锁存
+ ~5 C$ V3 W- o/ cuchar code teble[]={5 c- W/ b- Q. l3 {3 O5 t g
0x3f,0x06,0x5b,0x4f,
. |( f" t% q. Z0x66,0x6d,0x7d,0x07,
( l. l) u" y2 P( N( h5 P0x7f,0x6f,0x77,0x7c,) G7 J \- z, \& i" e b# o
0x39,0x5e,0x79,0x71}; D6 u2 ^2 R# ?" T- t; u1 M% j
uchar temp;- l8 c7 s, |1 l6 P! v2 ^7 B
uint num;
5 q' I5 ^4 @5 |5 \void delay(uint)
! b. n/ N) J% K6 ] f& Uvoid main()
2 t& B' r, e1 o3 O1 h9 p* }{% p3 w5 N2 `# ]" N# ~1 M7 y
temp=0xfe;
, G, u1 }1 I3 X' N) I3 A% K- K, F while(1)5 c3 t, o; x* _1 `2 Q( ]1 a! j
{
3 u: G* R8 u# B+ B. }- R for(num=0;num<16;num++)
3 ?3 \/ {$ j( w- ^# `7 G { wela=1;----------------------------位控制,希望依次点亮
) o* ]5 Q! o8 T$ F6 T. ] P0=temp;, O9 @% q" M4 Q
wela=0;+ W3 \1 X1 t3 x, C$ B2 ~
temp=_crol_(temp,1);2 s8 @* |* \9 @2 i
dula=1;----------------------------段控制,依次显示数字1.2.3.......
" L3 B/ W) {! ~ P0=table(num);
& w! x5 A" q. _) d" s7 ?2 M g8 ] dula=0;
6 {" ^% k# b! f- J& U delay(100);* c; a4 F5 N# O6 U" O1 a
}
) C* D0 x% ^' Z5 b, m }
; V8 P( k/ e" g}) n' A, m+ x# d
void delay(uint z)& C) a6 W2 ?4 o% g5 y0 [5 T- K
{
3 Q0 d8 E7 ~4 S; L uint x,y;( Q' B8 Q; B2 m# S3 F8 V" @
for(x=z;x>0;x--)1 o1 z( E4 h1 ~9 z+ I- N+ c
for(y=1000;y>0;y--);
8 i9 v+ q- |3 w2 r} |
-
-
|