标题: 8255A方式0的PAPB驱动荔枝 [打印本页]

作者: xianfajushi    时间: 2024-7-2 07:40
标题: 8255A方式0的PAPB驱动荔枝
这个荔枝随意拿个程序添加而成,前些天回复16按键对应16LED的,这个8255标题看代码和电路图关注与8255A有关的部分即可.
  1. #include "reg52.h"
  2. sbit A08255=P2^5;
  3. sbit CS8255=P2^6;
  4. void main()
  5. {//缘由http://www.51hei.com/bbs/dpj-236599-1.html
  6.         unsigned char sy=0,ys=0,my=0,ls=0,a=0,n=0,f=1;
  7.         A08255=f;
  8.         while(1)
  9.         {//模拟16按键,仿真图上放置一片AT89C52芯片,//什么电路都不接LED、按键也没有,就能仿真验证程序。
  10.                 if(++sy==0)if(++ys>47)
  11.                 {ys=0;
  12.                         if(a<128)
  13.                         {
  14.                                 if(a)a*=2;
  15.                                 else {a=1;A08255=f%2;}
  16.                                 CS8255=1;
  17.                                 P1=255-a;
  18.                                 CS8255=0;
  19.                         }
  20.                         else
  21.                         {
  22.                                 P1=255;
  23.                                 if(n<128)if(n)n*=2;
  24.                                 else n=1;
  25.                                 else {a=n=0;P3=255;++f;}
  26.                                 P3=255-n;
  27.                         }
  28.                 }
  29.                 if(P1!=255&&++my==0){ls=P1;P0=ls;}//P2=255;
  30.                 if(P3!=255&&++my==0){ls=P3;P2=ls;P0=255;}
  31.                 if(P1==255&&P3==255)my=0;//按键消抖综合
  32.         }
  33. }
复制代码









欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1