找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 14002|回复: 3
打印 上一主题 下一主题
收起左侧

51单片机5分钟倒计时程序+仿真图(数码管显示)

[复制链接]
跳转到指定楼层
楼主
基于51单片机的5分钟倒计时程序+仿真


单片机源程序如下:
  1. #include<reg51.h>
  2. unsigned char Seg_CA_Data[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
  3. unsigned char Seg_CA_Position[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
  4. void DelayTime10ms(unsigned int DelayValue);
  5. void Seg_Display_Second(unsigned char DisData,unsigned char Seg_Number);
  6. void Seg_Display_Minute(unsigned char DisData,unsigned char Seg_Number);
  7. void main()
  8. {
  9. unsigned char Second =59;
  10. unsigned char Minute=0x04;
  11. unsigned char         Count=10;
  12. for(;;)
  13. {
  14. while(        Count--)
  15. {
  16. Seg_Display_Second(Second,2);
  17. Seg_Display_Minute(Minute,2);
  18. }
  19. Count=10;
  20. if(Second--==0)
  21. {
  22. Second=59;
  23. if(Minute--==0)
  24. {
  25. Second=59;
  26. Minute=4;

  27. }
  28. }
  29. }
  30. }
  31. void DelayTime10ms(unsigned int DelayValue)
  32. {
  33. unsigned int a,b;
  34. for(a=0;a<DelayValue;a++)
  35. for(b=0;b<1828;b++);
  36. }
  37. void Seg_Display_Second(unsigned char DisData,unsigned char Seg_Number)
  38. {
  39. unsigned char i=0;
  40. for(i=0;i<Seg_Number;i++)
  41. {
  42. P2=Seg_CA_Position[i];
  43. P0=Seg_CA_Data[DisData%10];
  44. DisData=DisData/10;
  45. DelayTime10ms(1);
  46. }
  47. }
  48.   void Seg_Display_Minute(unsigned char DisData,unsigned char Seg_Number)
  49. {
  50. unsigned char i=0;
  51. P2=Seg_CA_Position[2];
  52. P0=0xbf;
  53. DelayTime10ms(1);
  54. for(i=3;i<Seg_Number+3;i++)
  55. {
  56. P2=Seg_CA_Position[i];
  57. P0=Seg_CA_Data[DisData%10];
  58. DisData=DisData/10;
  59. DelayTime10ms(1);
  60. }
  61. }
复制代码

所有资料51hei提供下载:
5分钟 倒计时.zip (24.93 KB, 下载次数: 164)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:574077 发表于 2020-1-1 12:23 | 只看该作者
大佬牛逼
回复

使用道具 举报

板凳
ID:440525 发表于 2020-5-14 22:12 | 只看该作者
2个不行吗
回复

使用道具 举报

地板
ID:1037452 发表于 2022-6-28 18:19 | 只看该作者
为什么1秒钟那么快呀
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表