找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 4075|回復(fù): 0
收起左側(cè)

單片機(jī)視覺暫留原理實(shí)驗(yàn) Proteus仿真加源程序

[復(fù)制鏈接]
ID:175881 發(fā)表于 2017-3-29 23:18 | 顯示全部樓層 |閱讀模式
單片機(jī)視覺暫留原理實(shí)驗(yàn)的仿真原理圖(proteus工程文件可到本帖附件下載):

0.png
單片機(jī)源程序:
  1. //---------------------------------------------------------------------------
  2. // 程序名:  SZ7-1(1).c
  3. // 程序功能:視覺暫留原理實(shí)驗(yàn)程序
  4. //---------------------------------------------------------------------------
  5. #include<reg51.h>
  6. sbit LED=P2^7;                                   //定義LED接口
  7. void delay10ms(unsigned int count);

  8. //------------------------------- 主函數(shù)------------------------------

  9. main()
  10.   {
  11.     while (1)                                     //無限循環(huán)
  12.     {
  13.       LED=0;                                      //點(diǎn)亮LED
  14.       delay10ms(100);                             //調(diào)用延時(shí)模塊,延時(shí)1s
  15.       LED=1;                                      //熄滅LED
  16.       delay10ms(100);                             //調(diào)用延時(shí)模塊,延時(shí)1s                
  17.     }
  18. }     

  19. //------------------------------ 延時(shí)函數(shù) -----------------------------

  20. void delay10ms(unsigned int count)                //總延時(shí)時(shí)間為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. //----------------------------------------------------------------------------
復(fù)制代碼
程序2:
  1. //---------------------------------------------------------------------------
  2. // 程序名:  SZ7-1.c(2)
  3. // 程序功能:視覺暫留原理實(shí)驗(yàn)程序
  4. //---------------------------------------------------------------------------
  5. #include<reg51.h>
  6. sbit LED=P2^7;                                   //定義LED接口
  7. void delay10ms(unsigned int count);

  8. //------------------------------- 主函數(shù)------------------------------

  9. main()
  10.   {
  11.     while (1)                                    //無限循環(huán)
  12.     {
  13.       LED=0;                                     //點(diǎn)亮LED
  14.       delay10ms(1);                              //調(diào)用延時(shí)模塊,延時(shí)0.01s
  15.       LED=1;                                     //熄滅LED
  16.       delay10ms(1);                              //調(diào)用延時(shí)模塊,延時(shí)0.01s                
  17.     }
  18. }     

  19. //------------------------------ 延時(shí)函數(shù) -----------------------------
  20. void delay10ms(unsigned int count)              //總延時(shí)時(shí)間為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. //----------------------------------------------------------------------------
復(fù)制代碼

0.png


該系列源碼包含有很多非常經(jīng)典,代碼風(fēng)格十分規(guī)范,而且注釋詳細(xì)的單片機(jī)例程,還帶仿真,對(duì)于MCU學(xué)習(xí)特別是初學(xué)者是很有幫助的,全部源碼下載(共25個(gè)項(xiàng)目):http://www.torrancerestoration.com/bbs/dpj-79328-1.html

本例程下載(含proteus仿真工程文件與源碼):
單片機(jī)視覺暫留原理實(shí)驗(yàn).rar (35.18 KB, 下載次數(shù): 7)



回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表