几个单片机学习的简单程序文档格式.doc
- 文档编号:8439398
- 上传时间:2023-05-11
- 格式:DOC
- 页数:40
- 大小:100KB
几个单片机学习的简单程序文档格式.doc
《几个单片机学习的简单程序文档格式.doc》由会员分享,可在线阅读,更多相关《几个单片机学习的简单程序文档格式.doc(40页珍藏版)》请在冰点文库上搜索。
P0_4=0;
}
循环闪亮
P0_5=1;
//闪亮D1;
P0_5=0;
P0_6=1;
//闪亮D2;
P0_6=0;
P0_7=1;
//闪亮D3;
P0_7=0;
voiddelay();
delay();
delay();
voiddelay()
P0=0x10;
P0=0x20;
P0=0x40;
P0=0x80;
循环点亮
unsignedcharTab[4]={0x10,0x20,0x40,0x80};
P0=Tab[0];
P0=Tab[1];
P0=Tab[2];
P0=Tab[3];
循环点亮
unsignedinta=0;
for(a=0;
a<
4;
a++)
P0=Tab[a];
intrins.h>
P0=0x10;
for(a=0;
delay();
P0=_crol_(P0,1);
}
}
voiddelay()
数码管点亮5
P0=0;
P1=0x0c;
P0=0x6d;
P1_0=1;
delay();
P1_0=0;
P0=0xfe;
P1_1=1;
P1_1=0;
}
学号
{
P0=0x3f;
P1_0=1;
P1_0=0;
P0=0x7f;
P1_1=0;
delay();
P0=0x6f;
P0=0xbf;
P0=0x5b;
P0=0xdf;
P0=0x06;
P0=0xef;
P0=0x3f;
P0=0xf7;
P0=0x7d;
P0=0xfb;
P0=0x07;
P0=0xfd;
unsignedinta=0;
unsignedcharseg[]={0x3f,0x6f,0x5b,0x06,0x3f,0x7d,0x07,0x5b};
unsignedchardig[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
for(a=0;
8;
{
P0=seg[a];
P0=dig[a];
for(i=1000000000;
开关K0控制灯
#defineuintunsignedint
#defineucharunsigned char
sbitKey_ce=P1^3;
sbitDig_ce=P1^1;
sbitLed_ce=P1^2;
bitStat=0;
Led_ce=0;
P0_4=Stat;
P0=0x0e;
Dig_ce=1;
Dig_ce=0;
Key_ce=0;
if(P0_0==0)
{
Stat=~Stat;
}
Key_ce=1;
}
}
开关K0控制灯
#include<
voiddelayms(uint);
delayms(10);
if(P0_0==0)
{
voiddelayms(uinti)
uintj;
for(i;
i--)
for(j=10;
j>
j--);
sbitSeg_ce=P1^0;
ucharcodeseg1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
voidKeyscan();
Keyscan();
voidKeyscan()
unsignedcharTemp1,Temp2,Keynum;
P0=0;
Seg_ce=1;
Seg_ce=0;
P0=0xfe;
Dig_ce=1;
Dig_ce=0;
Key_ce=0;
Temp1=P0;
Temp1=Temp1&
0x0f;
if(Temp1!
=0x0f)
{
delayms(10);
Temp2=P0;
Temp2=Temp2&
if(Temp1==Temp2)
switch(Temp2)
{
case0x0e:
Keynum=0;
break;
case0x0d:
Keynum=1;
case0x0b:
Keynum=2;
case0x07:
Keynum=3;
default:
}
while(Temp2!
{
Temp2=P0;
Temp2=Temp2&
}
}
}
Key_ce=1;
P0=seg1[Keynum];
Seg_ce=1;
Seg_ce=0;
Dig_ce=1;
Dig_ce=0;
delayms
(1);
P0=0;
P0=0xfd;
Keynum=4;
Keynum=5;
Keynum=6;
Keynum=7;
P0=0xfb;
Keynum=8;
Keynum=9;
Keynum=10;
Keynum=11;
P0=0;
P0=0xf7;
Keynum=12;
Keynum=13;
Keynum=14;
Keynum=15;
中断1.1
voidmain()
{
bitStat=1;
P0=0;
P1=0x0c;
P1_2=0;
TH0=0x8a;
TL0=0xd0;
while
(1)
P0_4=Stat;
TMOD=0x01;
TR0=1;
if(TF0==1)
TF0=0;
Stat=~Stat;
TH0=0x8a;
TL0=0xd0;
中断1.2
sbitStat=P0^4;
TH0=0xa8;
TMOD=0x01;
Stat=0;
IE=0x82;
//EA=1;
ET0=1
TR0=1;
{
;
}
voidT0_time()interrupt1
TH0=0xa8;
Stat=~Stat;
中断2.1
sbitStat=P0^4;
unsignedchara;
/
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 几个 单片机 学习 简单 程序
![提示](https://static.bingdoc.com/images/bang_tan.gif)