標題: 今天的單片機流水燈作業(yè),很有成就感 [打印本頁]

作者: mazeqin    時間: 2017-11-22 16:32
標題: 今天的單片機流水燈作業(yè),很有成就感
嘻嘻嘻


單片機源程序如下:
  1. //3-7-7:使用數(shù)組的指針控制P2口流水燈
  2. #include<reg52.h>        //包含單片機寄存器定義的頭文件

  3. /*************************
  4. 延時函數(shù)
  5. *************************/
  6. void delay(void)       
  7.                 {
  8.                         unsigned char m,n;
  9.                                 for(m=0;m<250;m++)
  10.                                         for(n=0;n<250;n++)
  11.                                         ;
  12.                  }
  13. /*****}*********************
  14. 主函數(shù)
  15. **************************/
  16. void main(void)
  17.         {
  18.                 unsigned char i;
  19.         
  20.                 unsigned char Tab[]={
  21.                                                 0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,//單燈左移
  22.                                                 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,//單燈右移
  23.                                                 0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,0xff,//雙燈開合
  24.                                                 0x00,0x81,0xc3,0xe7,0xff,0xe7,0xc3,0x81,0x00};//全燈收放
  25.                                                 //流水燈控制碼數(shù)組
  26.                 unsigned char *p;        //定義無符號字符型指針
  27.                 p=Tab;                                //將數(shù)組首地址存入指針p
  28.                 while(1)                        //無限循環(huán)
  29.                         {
  30.                                 for(i=0;i<34;i++)        //共34個流水燈控制碼
  31. ……………………

  32. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
流水燈.rar (41.39 KB, 下載次數(shù): 4)







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