|
7七段數(shù)碼管.png (17.18 KB, 下載次數(shù): 36)
下載附件
2018-6-22 16:40 上傳
' t2 d$ k% F9 o
#include<reg51.h>, X3 P) W8 I ]7 U) c
#include<intrins.h>( e7 @. c% M% z, u/ o2 a
#define uchar unsigned char
p8 j+ J: ^' K/ _" K( O#define uint unsigned int- V# s7 m3 e2 |9 O7 s1 @* q/ b
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};! C: K4 s) S; @5 `5 @; V q# G; e
//延時
4 T. i# A }' [+ s# Xvoid DelayMS(uint x) G. d/ A. r0 P
{
. z# B2 I! Y7 nuchar t;
) w4 L2 [* x# m8 l/ }while(x--) for(t=0;t<120;t++);
/ D9 z5 C; ]& w- h3 J: _}4 ?* D! n' g* G, [
//主程序
& j* \) p, J8 s' i! x1 [void main(): n% Y# h+ ~+ t# [0 I
{9 W# c) a% ^: Y9 Q e+ b
uchar i=0;3 `: G1 C1 A. ]# _+ s9 i
P0=0x00;* G3 e: D9 j6 I! a$ s
while(1). [7 b3 y J% H
{( ?; ~) e- Y& g8 e1 Y: |! |
P0=~DSY_CODE;
2 @, O6 g- y9 U. }1 u2 wi=(i+1)%10;' i* p3 j {4 d
DelayMS(300);# @/ r! i3 y V! \$ [& a( n% @
}2 x' a; V% K9 _9 [9 T2 z3 _: t
} % o$ X/ D" e' l4 z; d. s
0 Y# V7 Z2 \. F1 r+ d( K
|
|