历史上的今天
今天是:2025年04月16日(星期三)
2020年04月16日 | 51单片机简单计时器
2020-04-16 来源:eefocus
#include #define uint8 unsigned char #define uint16 unsigned short int //数码管段码显示:0~f,不亮 uint8 code LED_Disp[] = {0xC0,0xF9,0xA4,0xB0, //这一组编码当中不包含小数点 0x99,0x92,0x82,0xF8, 0x80,0x90}; //十个分别显示 0 1 2 3 4 5 6 7 8 9 uint8 code LED_Disp1[] = {0x40,0x79,0x24,0x30, //这一个数组的编码中包含小数点 0x19,0x12,0x02,0x78, 0x00,0x10}; //十个分别显示 0 1 2 3 4 5 6 7 8 9 int minute = 0; int second = 0; void mDelay(uint16 mtime) { for(; mtime > 0; mtime--) { uint8 j = 244; while(--j); } } void LED_Disp_Seg7() { int minute_1; int minute_2; int second_1; int second_2 ; if(second == 60) { minute++; second = 0; } if(minute == 60) { minute = 0; } minute_1 = minute/10; minute_2 = minute%10; second_1 = second/10; second_2 = second%10; P2 = 0x7f; P0 = LED_Disp[second_2]; mDelay(5); P2 = 0xbf; P0 = LED_Disp[second_1]; mDelay(5); P2 = 0xdf; P0 = LED_Disp1[minute_2]; mDelay(5); P2 = 0xef; P0 = LED_Disp[minute_1]; mDelay(5); } void timeDelay(unsigned int time) { while(time--) { LED_Disp_Seg7(); } } void main() { while(1) { timeDelay(80); second++; } }
上一篇:51单片机编写60秒倒计时程序
下一篇:51单片机做一个计时器
史海拾趣
|
Wince下如何使用CreateDIBSection第四个参数返回的指针 我在Wince下打开了一张图片并且成功截取了图片 保存截图 使用CreateDIBSection大概如下(我那个也差不多是这样子,因为程序我没有拿回来): hBitmap=CreateDIBSection(hDc,(BITMAPINFO *)lpImgData,DIB_RGB_COLORS, &n ...… 查看全部问答> |
|
int rc = _sqlite3_open(_T(\"存储卡\\\\123.db\"), &m_db); if ( rc != SQLITE_OK ) { ASSERT(FALSE); } 打开不成功,如果是英文目录就没有问题!… 查看全部问答> |
|
我的6410裸奔已经起来了 牛人给的的一个简单的BOOT 代码已经可以在DDR里面运行 但是我没有设置变量创建的地址在哪 那6410是自动在内部8K的SRAM创建变量呢 等到满了8K ...… 查看全部问答> |
|
config.status: error: cannot find input file: config.h.in [root@localhost ntop-3.2]# make cd . && /bin/sh ./missing --run echo cd && /bin/sh /ntop-3.2/config.status config.h config.status: creating config.h config.status: error: cannot find input file: config.h.in make: * ...… 查看全部问答> |
|
最近在搞omap-l138 DDR2驱动,DDR芯片是:FMD4A16LCx–30A,遇到问题卡住了。问题是这样的: 发现DDR在操作时,会刷新数据也会变。 测试伪代码: for(i = 0; i <length;i++) { p = ddr_addrbase ...… 查看全部问答> |
|
为什么我的ADC12MEM0寄存器读出来最大值是255 #include unsigned char i=0,qianwei=0,baiwei=0,shiwei=0,gewei=0; #include \"1602.c\" unsigned int a[32]; unsigned int sum=0; unsigned int temp=0; void main() { &n ...… 查看全部问答> |




