標題: AT89C51點亮LED燈簡單實驗 [打印本頁]

作者: 1109039558    時間: 2018-3-29 16:58
標題: AT89C51點亮LED燈簡單實驗
該實驗主要是點亮LED燈,利用PROTUES 和Keil5制作,完美實現(xiàn)

單片機源程序如下:
  1. #include<reg51.h>
  2. #include<intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int
  5. uchar code dis_code[]={0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0xc0};
  6. void delay(uint t)
  7. {
  8.         uchar i;
  9.         while(t--)
  10.         for(i=0;i<200;i++);
  11. }
  12. void main()
  13. {
  14.         uchar i,j=0x80;
  15.         while(1)
  16.         {
  17.                 for(i=0;i<8;i++)
  18.                 {
  19.                         j=_crol_(j,1);//循環(huán)左移
  20.                         P0=dis_code[i];
  21.                         P2=j;
  22.                         delay(180);
  23.                 }
  24.         }
  25. }
復制代碼

所有資料51hei提供下載:
實驗4.rar (48.29 KB, 下載次數(shù): 21)







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