|
單片機(jī)視覺暫留原理實(shí)驗(yàn)的仿真原理圖(proteus工程文件可到本帖附件下載):
單片機(jī)源程序:
- //---------------------------------------------------------------------------
- // 程序名: SZ7-1(1).c
- // 程序功能:視覺暫留原理實(shí)驗(yàn)程序
- //---------------------------------------------------------------------------
- #include<reg51.h>
- sbit LED=P2^7; //定義LED接口
- void delay10ms(unsigned int count);
- //------------------------------- 主函數(shù)------------------------------
- main()
- {
- while (1) //無限循環(huán)
- {
- LED=0; //點(diǎn)亮LED
- delay10ms(100); //調(diào)用延時(shí)模塊,延時(shí)1s
- LED=1; //熄滅LED
- delay10ms(100); //調(diào)用延時(shí)模塊,延時(shí)1s
- }
- }
- //------------------------------ 延時(shí)函數(shù) -----------------------------
- void delay10ms(unsigned int count) //總延時(shí)時(shí)間為10ms*count
- {
- unsigned int i,j,k;
- for(i=0; i<count; i++)
- for(j=0; j<10; j++)
- for(k=0; k<120; k++);
- }
- //----------------------------------------------------------------------------
復(fù)制代碼 程序2:
- //---------------------------------------------------------------------------
- // 程序名: SZ7-1.c(2)
- // 程序功能:視覺暫留原理實(shí)驗(yàn)程序
- //---------------------------------------------------------------------------
- #include<reg51.h>
- sbit LED=P2^7; //定義LED接口
- void delay10ms(unsigned int count);
- //------------------------------- 主函數(shù)------------------------------
- main()
- {
- while (1) //無限循環(huán)
- {
- LED=0; //點(diǎn)亮LED
- delay10ms(1); //調(diào)用延時(shí)模塊,延時(shí)0.01s
- LED=1; //熄滅LED
- delay10ms(1); //調(diào)用延時(shí)模塊,延時(shí)0.01s
- }
- }
- //------------------------------ 延時(shí)函數(shù) -----------------------------
- void delay10ms(unsigned int count) //總延時(shí)時(shí)間為10ms*count
- {
- unsigned int i,j,k;
- for(i=0; i<count; i++)
- for(j=0; j<10; j++)
- for(k=0; k<120; k++);
- }
- //----------------------------------------------------------------------------
復(fù)制代碼
該系列源碼包含有很多非常經(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)
2017-3-29 23:17 上傳
點(diǎn)擊文件名下載附件
|
|