标题:
8255A方式0的PAPB驱动荔枝
[打印本页]
作者:
xianfajushi
时间:
2024-7-2 07:40
标题:
8255A方式0的PAPB驱动荔枝
这个荔枝随意拿个程序添加而成,前些天回复16按键对应16LED的,这个8255标题看代码和电路图关注与8255A有关的部分即可.
#include "reg52.h"
sbit A08255=P2^5;
sbit CS8255=P2^6;
void main()
{//缘由http://www.51hei.com/bbs/dpj-236599-1.html
unsigned char sy=0,ys=0,my=0,ls=0,a=0,n=0,f=1;
A08255=f;
while(1)
{//模拟16按键,仿真图上放置一片AT89C52芯片,//什么电路都不接LED、按键也没有,就能仿真验证程序。
if(++sy==0)if(++ys>47)
{ys=0;
if(a<128)
{
if(a)a*=2;
else {a=1;A08255=f%2;}
CS8255=1;
P1=255-a;
CS8255=0;
}
else
{
P1=255;
if(n<128)if(n)n*=2;
else n=1;
else {a=n=0;P3=255;++f;}
P3=255-n;
}
}
if(P1!=255&&++my==0){ls=P1;P0=ls;}//P2=255;
if(P3!=255&&++my==0){ls=P3;P2=ls;P0=255;}
if(P1==255&&P3==255)my=0;//按键消抖综合
}
}
复制代码
20240701162334.gif
(213.28 KB, 下载次数: 18)
下载附件
2024-7-2 07:37 上传
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1