標(biāo)題: 單片機(jī)鍵盤+8255與LED 修改地址 [打印本頁]

作者: Jlimin    時間: 2018-7-4 13:09
標(biāo)題: 單片機(jī)鍵盤+8255與LED 修改地址
8255與LED修改地址


單片機(jī)源程序如下:
  1. #include <reg51.h>
  2. #include<absacc.h>
  3. #define PA  XBYTE[0xff00]
  4. #define com XBYTE[0xff03]
  5. unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

  6. unsigned char temp=9;
  7. sbit key0=P3^2;
  8. sbit key1=P3^3;
  9. sbit c1=P3^4;
  10. sbit c2=P3^5;
  11. delay(unsigned int t)
  12. {
  13.         unsigned char k;
  14.         while(t--) for(k=0;k<120;k++);
  15. }
  16. key_scan()
  17. {
  18.         key1=1;
  19.         key0=1;
  20.         if(!key0) {delay(10);if(!key0){if(temp==9) temp=0;else temp++;while(!key0);}}
  21.         if(key1==0) {delay(10);if(key1==0){if(temp==0)temp=9;else temp--;while(!key1);}}
  22. }


  23. disp()
  24. {
  25.         PA=tab[temp];
  26.         c1=0;
  27.         delay(1);
  28. }
  29. main()
  30. {
  31.         com=0x80;
  32.         while(1)
  33.         {
  34.                 disp();
  35.                 key_scan();       
  36.         }
  37. }

復(fù)制代碼

所有資料51hei提供下載:
8255與LED 修改地址.zip (43.51 KB, 下載次數(shù): 18)









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