缘由如何用单片机+独立按键控制16*16LED点阵模块点亮和熄灭?求指导 - 24小时必答区
#include "reg52.h"
unsigned char code DuLiAnJian[]={1,2,4,8,16,32,64,128,254,253,251,247,239,223,191,127};
unsigned char code CHARCODE[12][8]={
//{0xFD,0xFD,0x0D,0xED,0xED,0xED,0x0D,0xFD},{0x0D,0xED,0xED,0xED,0x0D,0xFD,0xFD,0xFF},
//{0xFF,0xFF,0x00,0xFE,0xB9,0x7F,0x80,0xFF},{0x00,0xFE,0xB9,0x7F,0x80,0xFF,0xFF,0xFF},
//{0xEF,0xEF,0x0F,0xE0,0xEF,0x0F,0xFF,0x01},{0xDD,0xDD,0xDD,0xDD,0x01,0xFF,0xFF,0xFF},
//{0xBF,0xDD,0xEA,0xF7,0xE9,0x9E,0xBF,0x80},{0xBD,0xBD,0xBD,0xBD,0x80,0xBF,0xBF,0xFF},
//{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
//{0xFF,0xFF,0xA7,0xC7,0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
//{0x7F,0xBF,0xCF,0xE1,0xEF,0xEF,0xEF,0x00},{0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xFF,0xFF},
//{0xBF,0xBF,0xBD,0xBD,0xBD,0xBD,0xBD,0x80},{0xBD,0xBD,0xBD,0xBD,0xBD,0xBF,0xBF,0xFF},
//{0xFF,0xFF,0xFF,0x01,0x7D,0x7D,0x7D,0x7D},{0x7D,0x7D,0x7D,0x01,0xFF,0xFF,0xFF,0xFF},
//{0xFF,0xFF,0xFF,0x00,0xBF,0xBF,0xBF,0xBF},{0xBF,0xBF,0xBF,0x00,0xFF,0xFF,0xFF,0xFF},
//{0xFF,0x1F,0xFF,0x00,0xEF,0xDF,0xF7,0xF7},{0xF7,0x00,0xF7,0xF7,0x07,0xFF,0xFF,0xFF},
//{0xFE,0xFF,0xFF,0x00,0xFF,0x7E,0xBE,0xCE},{0xF2,0xFC,0xF2,0xCE,0xBE,0x7E,0x7E,0xFF},
//{0xFF,0xFF,0x1F,0x63,0x7B,0x7B,0x7B,0x0B},{0x7D,0x7D,0x7C,0x7D,0x7F,0x7F,0xFF,0xFF},
//{0xFF,0xDF,0xEF,0xF7,0xF9,0xBF,0x7F,0x80},{0xFF,0xFF,0xFD,0xFB,0xF7,0xCF,0xFF,0xFF},
{0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},{0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80},
{0x00,0x00,0x10,0x11,0x16,0x10,0x10,0xF0},{0x10,0x10,0x14,0x13,0x10,0x00,0x00,0x00},
{0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03},{0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00},
{0x80,0x82,0x82,0x82,0xFE,0x82,0x82,0x82},{0x82,0x82,0xFE,0x82,0x82,0x82,0x80,0x00},
{0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00},{0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00}
};
sbit ds=P1^0;//数据线 595的14脚
sbit shcp=P1^1;//数据输入时钟线 595的11脚
sbit stcp=P1^2;//输出存储器锁存时钟线 595的12脚
sbit mr=P1^3;//数据清零
bit k = 0;
void QuDong595(unsigned char sj)
{
unsigned char aa=8;
while(aa--)
{
ds=sj>>7;sj<<=1;//十六进制数据发送
shcp=1;//上升沿发生移位 上升沿时数据寄存器的数据锁存。
shcp=0;
}
stcp=0;
stcp=1;//上升沿将数据送到输出锁存器
stcp=0;
}
void main()
{
unsigned char wei=0,Xd=0,Sw=0;
unsigned int Ys=47474,Lx=0;
P0=P1=P2=P3=0;
while(1)
{
if(!--Ys)
{
P2=P3=255;mr=0;mr=1;
if(k){Sw=wei+2;QuDong595(DuLiAnJian[Xd]);QuDong595(0x00);}//后前
else{Sw=wei;QuDong595(0x00);QuDong595(DuLiAnJian[Xd]);}//后前
P3=~CHARCODE[Sw+1][Xd];//下
P2=~CHARCODE[Sw][Xd];//上
if(++Xd>=8){Xd=0;k=~k;++Lx;}
if(Lx>74){wei+=4;Lx=0;}
if(wei>=12)wei=0;
Ys=247;
}
}
}