单片机报告Word文档格式.docx

上传人:b****8 文档编号:22448617 上传时间:2023-02-04 格式:DOCX 页数:39 大小:1.03MB
下载 相关 举报
单片机报告Word文档格式.docx_第1页
第1页 / 共39页
单片机报告Word文档格式.docx_第2页
第2页 / 共39页
单片机报告Word文档格式.docx_第3页
第3页 / 共39页
单片机报告Word文档格式.docx_第4页
第4页 / 共39页
单片机报告Word文档格式.docx_第5页
第5页 / 共39页
点击查看更多>>
下载资源
资源描述

单片机报告Word文档格式.docx

《单片机报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《单片机报告Word文档格式.docx(39页珍藏版)》请在冰豆网上搜索。

单片机报告Word文档格式.docx

IT1=1;

while

(1);

2.按1次按键,1个LED闪烁;

按2次按键,2个LED闪烁;

按3个按键,3个LED闪烁;

按4次按键,4个LED闪烁。

继续按下按键,则LED全灭,如此循环。

uinti=0;

voiddisplay(uintx){

ucharm;

while(x--){

for(m=120;

m>

0;

m--);

}}

while

(1){

if(i==0){

P2=0x00;

if(i==1){

P2=0x01;

display(100);

if(i==2){

P2=0x03;

if(i==3){

P2=0x07;

if(i==4){

P2=0x0f;

if(i==05){

i=0;

}}}

综合训练

(二):

查询式键盘识别技术

将8个按键从0-7编号,在1个数码管上显示相应的键号。

如果按键改变,则显示也相应改变。

#include<

intrins.h>

uchartab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x00};

sbitP10=P1^0;

sbitP11=P1^1;

sbitP12=P1^2;

sbitP13=P1^3;

sbitP14=P1^4;

sbitP15=P1^5;

sbitP16=P1^6;

sbitP17=P1^7;

uchari,n,n0=0,n1=0,n2=0,n3=0,n4=0,n5=0,n6=0,n7=0;

P1=0x00;

if(P10==1){i=0;

if(P11==1){i=1;

}

if(P12==1){i=2;

if(P13==1){i=3;

if(P14==1){i=4;

if(P15==1){i=5;

if(P16==1){i=6;

if(P17==1){i=7;

P2=tab[i];

综合训练(三):

矩阵式键盘与显示

单片机的并行口P1接4*4矩阵键盘,以P1.0-P1.3作行线,P1.4-P1.7作列线,在4个数码管上显示每个按键的键号(0~F)。

扩展:

每按一次键,显示的数字左(右)移一位,并显示按键键号。

reg52.h>

#defineuintunsignedint

ucharvalue;

ucharcheckkey(void);

voiddelay(z);

uchartable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};

/**********************是否有键按下*******************/

ucharcheckkey(void)

{ucharn;

P1=0xf0;

//P1口高位(键盘列线)置一,低位置零

n=P1;

if(n!

=0xf0)

return1;

//有,返回一

else

return0;

}

//***********************延时函数***********************

voiddelay(z)

{intx,y;

for(x=z;

x>

=0;

x--)

for(y=122;

y>

y--);

voidmain()

{uchari,j;

while

(1)

{

if(checkkey()==1)//有键按下,这下面的括号要注意,一定要打上,否则出错

{delay(20);

if(checkkey()==1)//确实有键按下

i=P1;

P1=0x0f;

j=P1;

i=i|j;

switch(i){

case0xee:

//按键零

value=12;

break;

case0xed:

value=13;

case0xeb:

value=14;

case0xe7:

value=15;

case0xde:

value=8;

case0xdd:

value=9;

case0xdb:

value=10;

case0xd7:

value=11;

case0xbe:

value=4;

case0xbd:

value=5;

case0xbb:

value=6;

case0xb7:

value=7;

case0x7e:

value=0;

case0x7d:

value=1;

case0x7b:

value=2;

case0x77:

value=3;

default:

break;

while(checkkey()==1)//这里是等待松键

{checkkey();

P2=0x01;

P0=table[value];

delay(5);

}}

综合训练(五):

12864液晶显示器

利用单片机与12864液晶显示器显示自己的学号、姓名、专业等。

把矩阵式键盘加入。

要求进行软硬件设计,先用Keil和Proteus仿真,再用STARES598PCI实验仪进行软硬件综合调试,制作PCB电路板,在PCB电路板上调试成功。

PCB图:

math.h>

stdio.h>

#defineDisp_On0x3f//定义管脚的指令值,屏幕显示开

#defineDisp_Off0x3e//屏幕显示关

#defineCol_Add0x40//设置列地址

#definePage_Add0xb8//设置页地址

#defineStart_Line0xc0//设置显示起始行

#defineLcd_BusP0//定义数据口

sbitMcs=P3^5;

sbitScs=P3^6;

sbitEnable=P2^0;

sbitDi=P2^2;

sbitRW=P2^1;

sbitLcd_Rst=P3^7;

sbita0=ACC^0;

sbita1=ACC^1;

sbita2=ACC^2;

sbita3=ACC^3;

sbita4=ACC^4;

sbita5=ACC^5;

sbita6=ACC^6;

sbita7=ACC^7;

voidDelay(intnum);

voidDelay12864(unsignedintt);

voidwrite_com(unsignedcharcmdcode);

voidwrite_data(unsignedcharDispdata);

voidDisp_hanzi(void);

voidClr_Scr(void);

voidDisp_Img(unsignedcharcode*img);

voidDisp_Digit(unsignedcharpag,unsignedcharcol,unsignedcharcode*hzk);

voidDisp_Chinese(unsignedcharpag,unsignedcharcol,unsignedcharcode*hzk);

voidInit_lcd(void);

/*****************************************

名称:

字模,有汉字,数字,和图片

*****************************************/

//汉字

unsignedcharcodezhen[32]={

0x00,0xE4,0x2C,0x35,0xA6,0x74,0x2C,0x24,0x02,0xF2,0x1A,0xD6,0x12,0xF2,0x02,0x00,

0x40,0x3F,0x80,0x89,0x44,0x22,0x11,0x08,0x80,0x4F,0x30,0x0F,0x10,0x2F,0xC0,0x00};

/*"

颜"

0*/

unsignedcharcodeya[32]={

0x00,0x80,0x60,0xF8,0x07,0x08,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0x08,0x00,

0x01,0x00,0x00,0xFF,0x00,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x12,0x22,0x1E,0x00};

伟"

unsignedcharcodezhi[32]={

0x20,0x20,0xFF,0x20,0x24,0xF4,0x54,0x54,0x54,0xFF,0x54,0x55,0x56,0xF4,0x04,0x00,

0x00,0x00,0xFF,0x00,0x08,0x0B,0x19,0x69,0x09,0x0B,0x49,0x89,0x7D,0x0B,0x08,0x00};

博"

1*/

unsignedcharcodesheng[32]={

0x20,0x10,0x08,0xFC,0x57,0x54,0x54,0x55,0xFE,0x54,0x54,0x54,0x54,0x04,0x00,0x00,

0x44,0x44,0x24,0x27,0x15,0x0D,0x05,0xFF,0x05,0x0D,0x15,0x25,0x25,0x45,0x44,0x00};

集"

3*/

unsignedcharcodewu[32]={

0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00};

大"

4*/

unsignedcharcodeyi[32]={

0x40,0x42,0xCC,0x00,0x00,0xF8,0x88,0x88,0x88,0x08,0xFF,0x08,0x09,0xCA,0x08,0x00,

0x00,0x00,0x3F,0x90,0x68,0x1F,0x10,0x20,0x9F,0x40,0x27,0x18,0x26,0x41,0xF0,0x00};

诚"

5*/

unsignedcharcodexue[32]={

0x20,0x24,0xAC,0x75,0xA6,0x34,0x2C,0xA4,0xA0,0x9E,0x82,0x82,0x9E,0xA0,0x20,0x00,

0x49,0x49,0x24,0x52,0x89,0x7F,0x05,0x98,0x80,0x43,0x2C,0x10,0x2C,0x43,0x80,0x00};

毅"

6*/

unsignedcharcodegong[32]={

0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,

0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00};

学"

7*/

unsignedcharcodecheng[32]={

0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,

0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00};

院"

8*/

unsignedcharcodexue1[32]={

0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,

0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00};

9*/

unsignedcharcodehao[32]={

0x40,0x40,0x40,0x5F,0xD1,0x51,0x51,0x51,0x51,0x51,0x51,0x5F,0x40,0x40,0x40,0x00,

0x00,0x00,0x00,0x02,0x07,0x02,0x02,0x22,0x42,0x82,0x42,0x3E,0x00,0x00,0x00,0x00};

号"

A*/

unsignedcharcodenian[32]={

0x00,0x20,0x18,0xC7,0x44,0x44,0x44,0x44,0xFC,0x44,0x44,0x44,0x44,0x04,0x00,0x00,

0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00};

年"

B*/

unsignedcharcodeyue[32]={

0x00,0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,0x00,

0x80,0x40,0x30,0x0F,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x00,0x00,0x00};

月"

C*/

unsignedcharcoderi[32]={

0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,0x00,0x00};

日"

D*/

unsignedcharcodean[32]={

0x10,0x10,0x10,0xFF,0x90,0x20,0x98,0x88,0x88,0xE9,0x8E,0x88,0x88,0xA8,0x98,0x00,

0x02,0x42,0x81,0x7F,0x00,0x00,0x80,0x84,0x4B,0x28,0x10,0x28,0x47,0x80,0x00,0x00};

按"

E*/

unsignedcharcodeniu[32]={

0x20,0x10,0x2C,0xE7,0x24,0x24,0x00,0x82,0x82,0xFE,0x82,0x82,0xFE,0x00,0x00,0x00,

0x01,0x01,0x01,0x7F,0x21,0x11,0x40,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x40,0x00};

钮"

F*/

//数字

unsignedcharvalue[];

unsignedcharcodezero[16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00};

//0

unsignedcharcodeone[16]={0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00};

//1

unsignedcharcodetwo[16]={0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00};

//2

unsignedcharcodethree[16]={0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00};

//3

unsignedcharcodefour[16]={0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00};

//4

unsignedcharcodefive[16]={0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00};

//5

unsignedcharcodesix[16]={0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00};

//6

unsignedcharcodeseven[16]={0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00};

//7

unsignedcharcodeeight[16]={0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00};

//8

unsignedcharcodenine[16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00};

//9

unsignedcharcodeAA[16]={0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20};

//A

unsignedcharcodeBB[16]={0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00};

//B

unsignedcharcodeCC[16]={0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00};

//C

unsignedcharcodeDD[16]={0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00};

//D

unsignedcharcodeEE[16]={0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00};

//E

unsignedcharcodeFF[16]={0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00};

//F

unsignedcharcodemaohao[16]={0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1