找回密码
 立即注册

QQ登录

只需一步,快速开始

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

红蓝闪烁灯程序和proteus仿真

[复制链接]
跳转到指定楼层
楼主



单片机源程序如下:
  1. #include <reg52.h>
  2. #define uchar unsigned char
  3. #define uint unsigned int

  4. uchar code Pattern_1[]=
  5. {
  6.         0x0A,0x05,0x0A,0x05,0x0A,0x05,0x0F
  7. };
  8. uchar code Pattern_2[]=
  9. {
  10.         0x0A,0x05,0x0F,0x08,0x04,0x0C,0x02,0x01,0x03,0x0F
  11. };
  12. void DelayMS(uint x)
  13. {
  14.         uchar t;
  15.         while(x--)
  16.         {
  17.                  for(t=120;t>0;t--);
  18.         }
  19. }

  20. void main()
  21. {
  22.         uchar i,m,j,k;
  23.         while(1)
  24.         {
  25.                  for(i=0;i<7;i++)
  26.                 {
  27.       for(m=0;m<3;m++)
  28.       {
  29.                          P0=Pattern_1[i];
  30.                         DelayMS(100);
  31.       P0=0;
  32.       DelayMS(100);
  33.       }
  34.                 }       
  35.     for(j=0;j<10;j++)
  36.                 {
  37.       for(k=0;k<3;k++)
  38.       {
  39.                            P0=Pattern_2[j];
  40.                           DelayMS(100);
  41.         P0=0;
  42.         DelayMS(50);
  43.                   }       
  44.     }
  45.         }
  46. }
复制代码

Proteus8.16仿真下载: JD.7z (35.83 KB, 下载次数: 4)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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