標(biāo)題: STC單片機(jī)做的呼吸燈源代碼 [打印本頁]

作者: suifeng668    時(shí)間: 2017-11-17 08:57
標(biāo)題: STC單片機(jī)做的呼吸燈源代碼
51單片機(jī)做的呼吸燈源代碼
單片機(jī)源程序如下:
  1. #include<reg51.h>
  2. #define uint unsigned int
  3. #define uchar unsigned char

  4. //sbit LED0=P3^5;
  5. //sbit LED1=P3^4;
  6. //sbit LED2=P3^0;
  7. //sbit LED3=P3^1;
  8. //sbit LED4=P3^2;
  9. //sbit LED5=P3^3;

  10. uint cycle,high,low;

  11. void delay(uint t)
  12. {
  13.         while(t--);
  14. }

  15. void main()
  16. {
  17.         cycle=700;                                                                  //周期
  18.        
  19.         while(1)
  20.         {
  21.                  for(high=cycle-1;high>0;high--)                 //由亮變暗
  22.                 {
  23.                         P3=0xff;
  24.                         delay(high);
  25.                         P3=0x00;
  26.                         low=cycle-high;
  27.                         delay(low);
  28.                 }
  29.                 P3=0x00;
  30.                 delay(60000);

  31.                  for(high=1;high<cycle;high++)
  32.                 {                                                                        //由暗變亮
  33.                         P3=0xff;
  34.                         delay(high);
  35. ……………………

  36. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
STC呼吸燈.rar (24.94 KB, 下載次數(shù): 57)



作者: dht179    時(shí)間: 2018-1-19 20:22
很實(shí)在的效果,代碼很簡潔。




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1