標(biāo)題:
8255A方式0的PAPB驅(qū)動(dòng)荔枝
[打印本頁]
作者:
xianfajushi
時(shí)間:
2024-7-2 07:40
標(biāo)題:
8255A方式0的PAPB驅(qū)動(dòng)荔枝
這個(gè)荔枝隨意拿個(gè)程序添加而成,前些天回復(fù)16按鍵對(duì)應(yīng)16LED的,這個(gè)8255標(biāo)題看代碼和電路圖關(guān)注與8255A有關(guān)的部分即可.
#include "reg52.h"
sbit A08255=P2^5;
sbit CS8255=P2^6;
void main()
{//緣由http://www.torrancerestoration.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、按鍵也沒有,就能仿真驗(yàn)證程序。
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;//按鍵消抖綜合
}
}
復(fù)制代碼
20240701162334.gif
(213.28 KB, 下載次數(shù): 18)
下載附件
2024-7-2 07:37 上傳
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1