LED屏显示问题,本人学生,有些不懂,有前辈指教
#include "reg51.h"
#define OutByte() RCK = 0;RCK = 1
sbit A1 = P1^1;
sbit B1 = P1^2;
sbit SER = P1^6;
sbit SCK = P1^4;
sbit RCK = P1^5;
unsigned char code Z[128] = {
/*天 CCCEC */
0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x7F,0xFE,0x01,0x00,
0x01,0x00,0x02,0x80,0x02,0x40,0x04,0x20,
0x08,0x18,0x10,0x0E,0x20,0x04,0x40,0x00,
/*下 CCFC2 */
0x00,0x04,0x7F,0xFE,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0xC0,0x01,0x60,0x01,0x30,
0x01,0x20,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
/*无 CCEDE */
0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x7F,0xFE,0x01,0x80,
0x02,0x80,0x02,0x80,0x04,0x80,0x08,0x80,
0x10,0x82,0x20,0x82,0xC0,0x7E,0x00,0x00,
/*敌 CB5D0 */
0x00,0x40,0x0E,0x60,0x70,0x40,0x10,0x40,
0x10,0x7E,0xFE,0x88,0x10,0x88,0x10,0x88,
0x11,0x88,0x7E,0x50,0x42,0x50,0x42,0x20,
0x42,0x20,0x7E,0x50,0x01,0x8E,0x06,0x04
};
/*
void OutByte()
{
RCK = 0;
RCK = 1;
} */
void DelayMs(int ms)
{
int i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<100;j++);
}
}
void LineScan(char line)
{
switch(line)
{
case 0:A1 = 0;B1 = 0;
break;
case 1:A1 = 1;B1 = 0;
break;
case 2:A1 = 0;B1 = 1;
break;
case 3:A1 = 1;B1 = 1;
break;
default:
break;
}
}
void SendByte(char byte)
{
char i;
for(i = 0;i<8;i++)
{
if(byte & 0x01)SER = 1; //1000_0000
else SER = 0;
byte = byte >> 1;
SCK = 0;
SCK = 1; //数据提前2指令周期准备好
}
}
void main(void)
{
char i,j,k;
while(1)
{
for(k=0;k<=3;k++)
{
for(j=7;j>=0;j--)
{
for(i=3;i>=0;i--)
SendByte(~Z[i*8+k*2+(j/2)*32+j%2]); //为什么我总是显示不了4个子呢?J的方程怎么改怎么计算的呢?如何才能显示出4个字呀
}
LineScan(k);
OutByte();
DelayMs(3);
}
}
}
一周热门 更多>