单片机46191709

上传人:nt****6 文档编号:55793313 上传时间:2018-10-06 格式:DOC 页数:38 大小:162.50KB
返回 下载 相关 举报
单片机46191709_第1页
第1页 / 共38页
单片机46191709_第2页
第2页 / 共38页
单片机46191709_第3页
第3页 / 共38页
单片机46191709_第4页
第4页 / 共38页
单片机46191709_第5页
第5页 / 共38页
点击查看更多>>
资源描述

《单片机46191709》由会员分享,可在线阅读,更多相关《单片机46191709(38页珍藏版)》请在金锄头文库上搜索。

1、/*闪烁灯闪烁灯*/ #include #define uchar unsigned charvoid Mdelay(unsigned int t)/1ms 延时 uchar i; while(t-) for(i=0;i #define uchar unsigned char uchar m=0;void main(void) TMOD=0x01; TH0=0x3c; TL0=0xb0; EA=1; ET0=1;TR0=1;while(1); void time0() interrupt 1 using 1 TH0=0x3c; TL0=0xb0;m+;if(m=20) P0=P0;m=0; /

2、*流水灯流水灯*/ #include #define uchar unsigned charvoid Mdelay(unsigned int t)/延时 uchar i; while(t-) for(i=0;i #include “intrins.h“ #define uchar unsigned charuchar j=0xfe;void Mdelay(unsigned int t)/延时 uchar i; while(t-) for(i=0;i #include “intrins.h“ #define uchar unsigned char uchar m=0,j=0xfe;void ma

3、in(void) TMOD=0x01; TH0=0x3c; TL0=0xb0; EA=1; ET0=1;TR0=1;while(1); void time0() interrupt 1 using 1 TH0=0x3c; TL0=0xb0;m+;if(m=20) P0=j;j=_crol_(j,1);m=0; /*数码管显示数码管显示 12345678*/ #include #define uchar unsigned char sbit CS1=P27; sbit CS2=P26; sbit LEDWR=P25; uchar code tab=0xf9,0xa4,0xb0, 0x99,0x9

4、2,0x82,0xf8,0x80; void Mdelay(unsigned int t)/延时 uchar i; while(t-) for(i=0;i #include “intrins.h“ #define uchar unsigned char sbit CS1=P27; sbit CS2=P26; sbit LEDWR=P25; uchar code tab=0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8,0x80;uchar j=0xfe,n=0; void Mdelay(unsigned int t)/延时 uchar i; while(t-) for(i

5、=0;i #include “intrins.h“ #define uchar unsigned char #define uint unsigned int uint count=0,n=0,j=0xfe; uchar code tab=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; uchar buf=0,0,10,10,10,10,10,10; sbit CS1=P27; sbit CS2=P26; sbit WWR=P25;void keyscan(); void display(); void mdelay(uint t

6、); void main() while(1) keyscan(); display(); void keyscan() uchar key; P1=P1|0x07; if(key=P1|0xf8)!=0xff) mdelay(25); P1=P1|0x07;if(key=P1|0xf8)!=0xff) if(key=0xfe) count+; if(count=100) count=0; if(key=0xfd) count-; if(count=-1)count=0; if(key=0xfb) count=0; P1=P1|0x07; while(key=P1|0xf8)!=0xff);

7、void mdelay(uint t) uchar i; while(t-) for(i=0;i #include “intrins.h“ #define uchar unsigned char #define uint unsigned int uint count=0,n=0,j=0xfe; uchar code tab=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; uchar buf=0,0,10,10,10,10,10,10; sbit CS1=P27; sbit CS2=P26; sbit WWR=P25;void k

8、eyscan(); void display(); void mdelay(uint t);void main() TMOD=0x01; TH0=0xfc; TL0=0x18; EA=1; ET0=1; TR0=1; while(1) keyscan(); void time0() interrupt 1 TH0=0xfc; TL0=0x18;display(); void keyscan() uchar key;P1=P1|0x07;if(key=P1|0xf8)!=0xff) mdelay(25);P1=P1|0x07;if(key=P1|0xf8)!=0xff) if(key=0xfe)

9、 count+; if(count=100) count=0; if(key=0xfd) count-; if(count=-1) count=0; if(key=0xfb) count=0; P1=P1|0x07; while(key=P1|0xf8)!=0xff); void mdelay(uint t) uchar i; while(t-) for(i=0;i #include #define uchar unsigned char #define uint unsigned int sbit CS1=P27; sbit CS2=P26; sbit WWR=P25; uchar code

10、 tab=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; uchar buf8=0,0,0,0,0,10,10,10; uint Count=0,Min=0,t=0; uchar n=0,j=0xfe;void Mdelay(uint m); void keyscan(); void Display();void main(void) TMOD=0x01; TH0=0x3c; TL0=0xb0; EA=1; ET0=1;while(1) keyscan(); Display(); void time0() interrupt 1

11、using 1 TH0=0xfc; TL0=0x18;t+; if(t=100) t=0;Count+; if(Count=600) Count=0;Min+;if(Min=60)Min=0; void keyscan(void) uchar key;P1=P1|0x07;if(key=P1|0xf8)!=0xff)Mdelay(25);P1=P1|0x07;if(key=P1|0xf8)!=0xff)if(key=0xfe)TR0=1;if(key=0xfd) TR0=0;if(key=0xfb)Count=0;Min=0;TR0=0;P1=P1|0x07;while(key=P1|0xf8

12、)!=0xff); void Mdelay(uint m) uchar i;while(m-)for(i=0;i #include “intrins.h“ #define uchar unsigned char #define uint unsigned int uint count=0,n=0,j=0xfe,m=0; uchar code tab=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff; uchar buf=0,0,10,10,10,10,10,10; sbit CS1=P27; sbit CS2=P26; sbit WW

13、R=P25;void keyscan(); void display(); void mdelay(uint t); void main() TMOD=0x01; TH0=0x3c; TL0=0xb0; EA=1; ET0=1; while(1) keyscan(); display(); void time0() interrupt 1 using 1 TH0=0xfc; TL0=0x18;m+; if(m=1000) m=0; count+; if(count=100) count=0; void keyscan() uchar key; P1=P1|0x07; if(key=P1|0xf

14、8)!=0xff) mdelay(25); P1=P1|0x07;if(key=P1|0xf8)!=0xff) if(key=0xfe) TR0=1; if(key=0xfd) TR0=0; if(key=0xfb) TR0=0;count=0; P1=P1|0x07; while(key=P1|0xf8)!=0xff); void mdelay(uint t) uchar i; while(t-) for(i=0;i #include #define uint unsigned int sbit CS1=P27; sbit CS2=P26; sbit wwr=P25; uint code t

15、ab=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x ff; uint buf=16,16,16,16,16,16,16,16; uint n=0,j=0xfe,p=0,count=0,m=0; void display(); void keyscan(); uint keydown(); void mdelay(uint t); void main() TMOD=0x01; TH0=0xfc; TL0=0x18; EA=1; ET0=1; while (1) display(); keyscan(); void time0() interrupt 1 TH0=0xfc; TL0=0x18; m+; if(m=100) m=0; if(p=1) count+;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号