一个好玩的C51动态扫描小程序
时间:11-30
来源:互联网
点击:
初学者上手的简单程序,把下面代码复制进keil代码窗口,烧进51hei开发板,看看结果吧
#include#define uchar unsigned char#define uint unsigned int#define dp P0char code DuanMa[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40}; //单个数码管显示数char code fenjie[]={0,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f};char code WeiMa[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //数码管的位选择:从0到7.sbit LATCH1=P2^6; // 控制数码管段的位sbit LATCH2=P2^7; // 控制数码管位的位void delay(unsigned int t){while(--t);}void main(){int i,j,k;while(1){delay(5000);for(i=0;i<7;i++) //段码{ for(j=0;j<8;j++) //位码{ for(k=0;k<10;k++) //调节k的值可调节扫描时间{dp=WeiMa[j]; //取位码LATCH2=1; LATCH2=0; dp=DuanMa[i]; //取段码 LATCH1=1; LATCH1=0;delay(2500);dp=fenjie[i]; //取段码 LATCH1=1; LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1; LATCH2=0; delay(50);dp=0; //取段码 清零 减小余晖影响LATCH1=1; LATCH1=0;dp=WeiMa[j]; //取位码LATCH2=1; LATCH2=0; delay(1000); }}} //闪烁8for(k=0;k<10;k++){dp=fenjie[7]; //取段码 LATCH1=1; LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1; LATCH2=0;delay(6000);delay(6000);dp=0; //取段码 LATCH1=1; LATCH1=0;dp=WeiMa[7]; //取位码LATCH2=1; LATCH2=0;delay(6000);} } }
C51动态扫 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)