|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
制作出来的实物图如下:
! @8 c) e- `/ F/ ^![]()
3 o$ O3 I- m4 G& m2 t7 Faltium Designer画的PCB图如下:
1 Y/ Z! P" Y9 x5 k* Q6 [" G# s7 L- r3 y$ l
" w# ?) l9 R6 i4 o
g! F9 x3 x0 U& O: X7 ?
单片机源程序如下:2 Q& L0 m) V0 y+ ^
include "reg51.h"
! z4 O$ Y( g- y) ^, m/ D. z#include "intrins.h"
; q3 @# H0 a+ _+ |, \' L% k8 @# A$ E& u. L. `
sfr P5 = 0xC8;1 N: k# \, h; z" s5 Y% Y
sfr P1M0 = 0X92;4 ]- _8 N `. N* P9 n5 p
sfr P1M1 = 0x91;
% y+ ^- }6 Y( a( D6 ]+ m2 [sfr P3M0 = 0XB2;# S) @" v' j% Z5 E1 U" C/ L/ M
sfr P3M1 = 0xB1;& q1 f, z. v5 U8 y
sfr P5M0 = 0XCA;
9 H, |- m+ I# X0 n1 a4 Gsfr P5M1 = 0xC9;9 b3 O' U& z H: D1 n
. Q" R+ s; B7 y1 s' W. ^0 p0 C) m
sbit S_RCLK = P1^7;//位移动信号* Y8 g8 _: U+ l2 t f
sbit L_RCLK = P1^6;//平行输出信号3 U& w& D, A( r3 Z$ n; T: ^
sbit S_BIT = P1^5;//位输入/ n) m) T& H- @6 K
, Y/ s0 L* E5 c3 ~$ q: S* C//bit ; //标志位,虚拟的按键
! W* b' P9 b4 R/ k) Q: f0 Punsigned char ct;
3 ]# a y2 u W. n//unsigned int //255 655361 d8 l* c: H" _$ r1 l
unsigned char code SEG_tab[]={0x3f,0x06,0x5b,0x4f," B2 Y* k0 P3 k0 M
0x66,0x6d,0x7d,0x07,+ u9 y( F0 S8 b0 K b8 V0 K8 V
0x7f,0x6f,0x77,0x7c,% Y1 H1 m* s4 _7 M: b7 P; u
0x39,0x5e,0x79,0x71,0x40,0x80};
7 V; C+ Z" E% N& U/ w3 a5 z3 |" l& O
void Send_595(unsigned char x);/ J: W5 U5 R& |0 h) \, y+ S
void Delay1ms();
$ Z" h" g' c! }+ B, D; |8 r
$ K' y4 l/ _4 H& ~3 `) N) Q' |: d6 o1 p: s! ?+ v5 X
main(void)1 Y' Q7 s; |2 _; x( v
{
4 A& l( ?4 D) I6 V" s P1M0 = 0X00;
) L, o" N, p: N; ` P1M1 = 0X00; //0000 0000
5 v$ x& h- }3 I P3M0 = 0X00; //0000 1000
% s5 Y- w' f# e( Y5 u7 a- O P3M1 = 0X00;
+ P: y# i8 |/ M P5M0 = 0X00; |; U- [% ]1 r4 x
P5M1 = 0X00;0 O. v u* K% p. h5 E# b6 C
L_RCLK = 0;" p+ q0 V& d2 a7 A, B
S_RCLK = 0;
6 M0 K7 t# q8 P/ w) ? S_BIT = 0;//位输入
, p6 u& d. D6 E0 ^ while(1)
1 Y! W+ ?# z$ x- f- N { . t0 p8 R P% T! D( Y! Q; h' ~* R
static unsigned char ct=0;
+ ]' j& s+ K- H x unsigned int j=0;
. z# W; a# s8 X2 G# C j=~(0x01<<ct);+ E" K' R; V( V& Y6 O Z4 J
Send_595(j>>8);//片选相数码管 位码高8位 2 q# q& m: Q S! o( O& V* b
Send_595(j);//片选相数码管 位码低8位
1 \0 y- @: u, ^% B# @ Send_595(SEG_tab[ct]);//数码管数据
' z) o& e" V: l L_RCLK = 1;* q) [! t% Y9 y+ q# \4 }1 c
L_RCLK = 0;3 Q( D. H! u0 _ B6 i( Q5 t& { k; H
Delay1ms();* c. C2 l ]7 \9 i1 s
if(ct<16)
6 {3 A% _# R$ D9 w. z {" |# r/ V% g2 l" \8 L! L' X$ w
ct++;% e# ^, h" B0 C) O' R3 e5 z! E0 `
}
' |5 G' g- b! Q- ? else ct=0;
7 P5 E M% J5 C2 T0 ^' l }: O' ~: _% [6 w8 b1 o. Y( J
}
" L4 y5 F$ ^, L7 V5 R3 m
2 u$ f5 g! J1 Z3 p8 z; m
/ k2 l2 V. x3 {- g4 m* Kvoid Send_595(unsigned char x)6 \: S& |& h" ]1 Z
{
0 E: N5 C- a7 o, s+ S4 Z unsigned char i;
9 t6 a$ |* B( _5 y# H- @ for(i=0;i<8;i++)& p# m' D$ _: Z. b2 ~
{" H# K5 }* Y% }7 O' D6 y/ j
if(x&0x80) S_BIT = 1;
8 G2 e! l1 f* H5 V+ w else S_BIT = 0;
/ v) K/ N7 V4 X+ V& r S_RCLK = 1;
9 V% ?8 k) ^# C7 Q S_RCLK = 0;
1 Q$ W0 D: [7 l x = x<<1;
/ H2 I5 D6 w; l' S T! r }
4 |1 y' s: p9 {- v3 v8 x4 D/ }}: m, U7 f0 s0 z$ Y
# o5 ^1 E" b; `4 avoid Delay1ms() //@11.0592MHz. @- `4 t% j5 O- h: s" }4 @
{" Y0 `& e/ k. e- a
unsigned char i, j;
& I1 ?! U; O$ a0 k. V3 Q' r) M
6 d! J7 T) r; \9 ] I( { i = 15;
2 ~0 C) h: ~' u! ]3 G- V6 t: d j = 90;! W/ N" D% B! ?" ^7 {6 a
do: {: M/ t0 l! Z, `* h
{; J/ \2 H1 ?! b: f4 d4 ^
while (--j);! ^5 T7 z0 G& `# A) _! P9 b$ c- P
} while (--i);$ J( C5 y1 ]/ b2 K+ W- b3 C
}& w: U. A7 Z2 z3 O
|
|