|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
单片机0-9999四位数秒器 电路环境proteus8.0仿真! x: w+ }! L" c8 ~) j
/ L; ]- k; s. s6 ]" i. G5 j% Y; {2 ]
; G0 Q" o1 D$ ~% ~& X- }四位数秒器,电路环境proteus8.0
$ t2 ?- g" Y: f6 ~单片机源程序:
+ e) Q. t( v- l5 q& v#include <reg51.h>
& O2 l6 F& z) ?3 J% K3 L r. s6 M. yunsigned char code table[]=# d" H8 ]' l; S* i% C
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
: h7 q! V5 f! }5 Hunsigned int m=0;6 E! e, ]) Y; `; b# p3 ~
sbit P20=P2^0; //m的个位控制
& [0 B+ R' W [; a% asbit P21=P2^1; //m的十位控制
# x: ]) M3 L: ^6 vsbit P22=P2^2; //m的百位控制( \5 W0 S( |2 s
sbit P23=P2^3; //m的千位控制
' r& u6 a9 s- s+ F1 S9 o4 C! \5 u7 @5 h3 j! H" v5 d- Y2 ~
void delay1ms();; e# q% e( d8 [3 K
void display();
8 Z: d$ C/ ]5 w0 o! {: _" k. O2 V2 G! w8 o8 Z' \
main()! O, D+ J A2 |7 b" p: R
{
+ B# `9 }9 j0 c% W2 r unsigned char i;
' s1 H4 p: \1 e& v# j while(1)% M- s: }- D: E$ D9 Y7 r
{
3 w9 W' e0 C; Z- U* D for(i=250;i>0;i--)display();) i* C. n- d. C/ i2 b U
m++;$ N1 A. s: W% U! b
if(m>=10000)m=0;3 y, R1 S7 N& u1 H6 N9 H6 [9 x0 O/ ]
}
# r, ^' V" @1 s& Z6 N; _- y+ T x7 O}
) Z5 h/ X( w h! k3 z3 r% G( j8 D7 i) h! j
void delay1ms()
4 r3 f& N3 B' E0 P9 Z& K& l$ _{
5 R7 ?: R/ h1 Y# Y Y8 Z7 C. \ unsigned char i;
6 {0 W8 T2 L0 c9 A1 x+ d for(i=248;i>0;i--);
' w, z2 t- U8 e for(i=248;i>0;i--);
$ _% h' S5 G0 V) z} O" Z1 S- K: X1 u r5 A- z5 n
( c- l: o' M! @" ^0 `) Hvoid display()4 R( M0 D0 r ?- v+ O( {2 n; L7 \
{9 V& C5 {$ \3 M6 }: ]
P2=0xff;3 o% a! ~: b) V9 [
P0=table[m%10];
# f% ]9 g: g1 ~. ] P20=0;
0 h% Q" ~; L" @4 h% q$ i5 C/ l" Z/ n delay1ms();
1 `0 q! ^, N/ n/ Y% g2 S. A5 h8 B ?% {9 r
P2=0xff;
/ K* r2 a+ Y7 _' L P0=table[m/10%10];
6 h9 h1 w/ x5 R& E4 h8 t P21=0;
8 \ a8 I6 r% k7 a7 _+ E! L5 C' i delay1ms();7 s0 b5 o) t( O' c5 [- b
" R' m" E! |) d. S+ D& K P2=0xff;# V6 f% t% p/ Z$ I
P0=table[m/100%10];7 _( I4 c* B$ p% R" P
P22=0;% M r+ s, K+ R# p6 d1 Q
delay1ms();
( C3 d1 a' [' v g. x0 m1 G" E! D5 H3 v$ N
…………限于本文篇幅 余下代码请从论坛下载附件…………
% I# \& d, m) t
; }: z4 M0 `0 d% o2 q# S2 n
! E1 J8 Y4 l8 j5 S( I2 Y% K |
|