标题: 51单片机5分钟倒计时程序+仿真图(数码管显示) [打印本页]

作者: ljx19961003    时间: 2018-12-14 15:49
标题: 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, 下载次数: 167)



作者: 2273842343    时间: 2020-1-1 12:23
大佬牛逼
作者: 2848979116    时间: 2020-5-14 22:12
2个不行吗
作者: 琪琪i    时间: 2022-6-28 18:19
为什么1秒钟那么快呀




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1