标题: 单片机视觉暂留原理实验 Proteus仿真加源程序 [打印本页]

作者: 51黑电子happy    时间: 2017-3-29 23:18
标题: 单片机视觉暂留原理实验 Proteus仿真加源程序
单片机视觉暂留原理实验的仿真原理图(proteus工程文件可到本帖附件下载):


单片机源程序:
  1. //---------------------------------------------------------------------------
  2. // 程序名:  SZ7-1(1).c
  3. // 程序功能:视觉暂留原理实验程序
  4. //---------------------------------------------------------------------------
  5. #include<reg51.h>
  6. sbit LED=P2^7;                                   //定义LED接口
  7. void delay10ms(unsigned int count);

  8. //------------------------------- 主函数------------------------------

  9. main()
  10.   {
  11.     while (1)                                     //无限循环
  12.     {
  13.       LED=0;                                      //点亮LED
  14.       delay10ms(100);                             //调用延时模块,延时1s
  15.       LED=1;                                      //熄灭LED
  16.       delay10ms(100);                             //调用延时模块,延时1s                
  17.     }
  18. }     

  19. //------------------------------ 延时函数 -----------------------------

  20. void delay10ms(unsigned int count)                //总延时时间为10ms*count
  21.   {  
  22.     unsigned int i,j,k;         
  23.         for(i=0; i<count; i++)
  24.         for(j=0; j<10; j++)   
  25.                    for(k=0; k<120; k++);
  26.   }

  27. //----------------------------------------------------------------------------
复制代码
程序2:
  1. //---------------------------------------------------------------------------
  2. // 程序名:  SZ7-1.c(2)
  3. // 程序功能:视觉暂留原理实验程序
  4. //---------------------------------------------------------------------------
  5. #include<reg51.h>
  6. sbit LED=P2^7;                                   //定义LED接口
  7. void delay10ms(unsigned int count);

  8. //------------------------------- 主函数------------------------------

  9. main()
  10.   {
  11.     while (1)                                    //无限循环
  12.     {
  13.       LED=0;                                     //点亮LED
  14.       delay10ms(1);                              //调用延时模块,延时0.01s
  15.       LED=1;                                     //熄灭LED
  16.       delay10ms(1);                              //调用延时模块,延时0.01s                
  17.     }
  18. }     

  19. //------------------------------ 延时函数 -----------------------------
  20. void delay10ms(unsigned int count)              //总延时时间为10ms*count
  21.   {  
  22.     unsigned int i,j,k;         
  23.         for(i=0; i<count; i++)
  24.         for(j=0; j<10; j++)   
  25.                    for(k=0; k<120; k++);
  26.   }
  27. //----------------------------------------------------------------------------
复制代码




该系列源码包含有很多非常经典,代码风格十分规范,而且注释详细的单片机例程,还带仿真,对于MCU学习特别是初学者是很有帮助的,全部源码下载(共25个项目):http://www.51hei.com/bbs/dpj-79328-1.html

本例程下载(含proteus仿真工程文件与源码):
单片机视觉暂留原理实验.rar (35.18 KB, 下载次数: 7)








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