微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 数码管和流水灯同时工作

数码管和流水灯同时工作

时间:08-24 来源:互联网 点击:
#includereg52.h>#define uint unsigned int#define uchar unsigned charuchar code temp[]={0x80,0xe3,0x44,0x41,0x23,0x11,0x10,0xc3,0x00,0x01};
//数码管由0~9的显示char code b[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,
0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x01,0x03,0x07,0x0f,0x1f,
0x3f,0x7f,0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};//流水灯先是逐个闪动,
后反向闪动,再全部闪动,再反向全部闪动。void delay(uint time)//延时函数{while(time--);}void main() //主函数{uint k,l;uchar i,j;j=0;while(1){for(i=0;i10;i++){P1=temp;P2=b[j]; for(l=0;l100;l++)for(k=0;k5;k++)delay(10);j++;if(j==38)j=0;}}}缺点:单片机两个IO口不能同时独立工作!  

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top