51单片机应用实例小制作
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
51单片机应用实例小制作16x16点阵显示屏、蜂鸣器、独立键盘
制作:赵建业
2016/12/1
原理图(总体)
原
理
图
(
芯
片
)原理图(16x16LED点阵)
功能说明:
1、通电后进入问候界面。
2、四个按键(实时有效):
1> GIF:按下后进入动画显示模式。
2> WORLD:按下后进入文字显示模式。
3> MUSIC:按下后进入音乐模式,由于51硬件限制,暂时不能同时显示16x16点阵。
4> NEXT:按下后,切换当前模式的下一个内容。为循环播放。
3、滑动变阻器:音乐模式下调节音量大小。
注意事项:
1、程序代码由于在world中保存格式原因,复制到编译软件后可能会出现错误。或可以向本人索要源代码。
2、由于本程序内容较多,占用内存较大,89c51的内存放不下,因此需要用89c52或更高版本芯片。它们只是内存大小不容。
程序代码:
#include <>
#include <>
#include"" //自定义音符头文件
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define KEY P2
sbit sound=P1^6;
sbit MOSIO = P1^0;
sbit R_CLK = P1^1;
sbit S_CLK = P1^2;
unsigned char Keymun1,Keymun2;//存按键序号
unsigned char Keystay;//按键状态,有按键按下为1,无按键按下为0
unsigned int C;
unsigned char x,y;
uchar code tab0[] = {0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80,
0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00};
uchar code hi[]={
0,0,0,0,0,0,3,12,2,12,2,0,2,0,58,14,70,8,66,8,66,8,66,8,66,8,231,62,0,0,0,0
};//开机问候语:“hi”
uchar code jif1[22][32] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,128,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,192,3,64,2,64,2,192,3,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,224,7,32,4,160,5,160,5,32,4,224,7,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,240,15,16,8,208,11,80,10,80,10,208,11,16,8,240,15,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,248,31,8,16,232,23,40,20,168,21,168,21,40,20,232,23,8,16,248,31,0,0,0,0,0,0,
0,0,0,0,252,63,4,32,244,47,20,40,212,43,84,42,84,42,212,43,20,40,244,47,4,32,252,63,0,0,0,0,
0,0,254,127,2,64,250,95,10,80,234,87,42,84,170,85,170,85,42,84,234,87,10,80,250,95,2,64,254,127,0,0, 255,255,1,128,253,191,5,160,245,175,21,168,213,171,85,170,85,170,213,171,21,168,245,175,5,160,253,191, 1,128,255,255,
128,1,128,1,128,1,128,1,128,1,128,1,128,1,255,255,255,255,128,1,128,1,128,1,128,1,128,1,128,1,128,1,
1,128,3,192,6,96,12,48,24,24,48,12,96,6,192,3,128,1,192,3,96,6,48,12,24,24,12,48,6,96,3,192,
128,1,128,1,128,1,128,1,128,1,128,1,128,1,255,255,255,255,128,1,128,1,128,1,128,1,128,1,128,1,128,1,
1,128,3,192,6,96,12,48,24,24,48,12,96,6,192,3,128,1,192,3,96,6,48,12,24,24,12,48,6,96,3,192,
128,1,128,1,128,1,128,1,128,1,128,1,128,1,255,255,255,255,128,1,128,1,128,1,128,1,128,1,128,1,128,1,
1,128,3,192,6,96,12,48,24,24,48,12,96,6,192,3,128,1,192,3,96,6,48,12,24,24,12,48,6,96,3,192,
128,1,128,1,128,1,128,1,128,1,128,1,128,1,255,255,255,255,128,1,128,1,128,1,128,1,128,1,128,1,128,1, 64,2,64,2,64,2,64,2,64,2,64,2,127,254,0,0,0,0,127,254,64,2,64,2,64,2,64,2,64,2,64,2,
32,4,32,4,32,4,32,4,32,4,63,252,0,0,0,0,0,0,0,0,63,252,32,4,32,4,32,4,32,4,32,4,
16,8,16,8,16,8,16,8,31,248,0,0,0,0,0,0,0,0,0,0,0,0,31,248,16,8,16,8,16,8,16,8,
8,16,8,16,8,16,15,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,240,8,16,8,16,8,16,
4,32,4,32,7,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,224,4,32,4,32,