LED点阵
LED点阵(32*128)显示程序+图片(C语言格式)
LED点阵显示,如有做点阵显示的可以拷贝一下
在现实中用肉眼可以清晰的看到“西华大学”四个大字
;---------------------------------------------------------------------------
程序如下:
//--------------------------------
//名称:C语言实现汉字显示(12c4052)
//作者:wanchun311
//日期:2008年12月15日
//--------------------------------
#include "reg51.h"
#define uchar unsigned char
#define uint unsigned int
sbit CP =P1^0 ; //74HC595移时钟
sbit SCK =P1^1 ; // 74HC595锁存信号
sbit Red=P1^2 ; //红色数据输出引脚低电平有效
sbit Greed=P1^3; // 绿色数据输出引脚低电平有效
sbit Gen1=P1^4 ; //全屏控制使能1,高电平有效
sbit Gen2=P3^5 ; //全屏控制使能2,高电平有效
sbit G1 = P3^7 ; //半屏控制使能
uchar SendData;
uchar i; //换屏变量
uchar j; //换行变量
uchar m1; //每次发送数据的 起始地址
uchar code data1[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x00,0x01,0xFE,0x00,0x00,0x1F,0xF0,0x00,0x01,0xFC,0x80,0x00,
0x00,0x10,0xC0,0x00,0x00,0x18,0xC0,0x00,0x00,0x18,0xC0,0x00,0x00,0x18,0xC0,0x00,
0x00,0x18,0xC1,0xE0,0x00,0x19,0xFF,0xF0,0x1B,0xFF,0x80,0x78,0x0E,0x10,0x80,0x70,
0x0C,0x10,0x80,0x70,0x04,0x10,0xC0,0x70,0x04,0x30,0x7C,0x70,0x06,0x20,0x00,0x60,
0x06,0x20,0x00,0x60,0x06,0x40,0x00,0x60,0x06,0x00,0x00,0xE0,0x02,0x03,0xF8,0xC0,
0x03,0xFF,0xFC,0xC0,0x03,0x80,0x07,0xC0,0x02,0x00,0x03,0xC0,0x00,0x00,0x03,0x80,
0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};/*"西",0*/
uchar code data2[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xC0,0x00,0x00,0x18,0xE0,0x00,
0x00,0x38,0xC2,0x00,0x00,0x30,0x43,0x00,0x00,0x60,0x47,0x00,0x00,0x60,0x4E,0x00,
0x00,0xE0,0x58,0x00,0x01,0xA0,0x70,0x00,0x03,0x20,0xC0,0x00,0x06,0x23,0x40,0x40,
0x0C,0x20,0x40,0x40,0x00,0x20,0x40,0xC0,0x00,0x20,0x7F,0xE0,0x00,0x60,0x3F,0xC0,
0x00,0x63,0x00,0x00,0x00,0x21,0x80,0x00,0x00,0x01,0x80,0xF0,0x00,0x01,0xFF,0xFC,
0x03,0xFF,0xE0,0x00,0x1F,0xC1,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x00,0x01,0x80,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,
};/*"华",1*/
uchar code data3[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0E,0x00,0x00,
0x00,0x07,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,
0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x06,0x1F,0x80,
0x00,0x07,0xFF,0x80,0x00,0x3F,0xC0,0x00,0x07,0xFE,0x00,0x00,0x00,0x06,0x00,0x00,
0x00,0x06,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x0D,0x80,0x00,0x00,0x0C,0xC0,0x00,
0x00,0x18,0xC0,0x00,0x00,0x18,0x60,0x00,0x00,0x30,0x30,0x00,0x00,0x60,0x38,0x00,
0x00,0xC0,0x1E,0x00,0x01,0x80,0x0F,0x00,0x03,0x00,0x07,0xE0,0x0C,0x00,0x07,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"大",2*/
};
uchar code data4[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x06,0x00,0x00,0x06,0x06,0x00,
0x00,0xC3,0x0E,0x00,0x00,0x63,0x8C,0x00,0x00,0x71,0x88,0x00,0x00,0x21,0x08,0x00,
0x00,0x00,0x10,0x00,0x00,0x00,0x13,0xE0,0x04,0x07,0xFC,0x78,0x07,0xFC,0x00,0x70,
0x06,0x00,0x00,0xC0,0x0E,0x00,0x60,0x80,0x1C,0x0F,0xF0,0x00,0x1C,0x3C,0x38,0x00,
0x08,0x00,0x60,0x00,0x00,0x00,0xC0,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x8F,0xE0,
0x00,0x07,0xFF,0xE0,0x03,0xFF,0xC0,0x00,0x0F,0x80,0xC0,0x00,0x00,0x00,0xC0,0x00,
0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0xC0,0x00,
0x00,0x0C,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x03,0x80,0x00,0x00,0x01,0x00,0x00,
};/*"学",3*/
//------------------------------------
//----------字发送子程序-----------
void SendByte(void)
{
uchar m;
for(m=0;m<8;m++)
{
CP = 0;
Red = !(SendData & 0x80);
// Greed = SendData &&0x01 ;
SendData =SendData<<1;
CP = 1;
}
}
//--------------------------------------
//-----------换屏显示-------------------
void Huanping(void)
{
j++ ;
if(j==0x02)
{
Gen1 =!Gen1;
Gen2 = !Gen2;
j = 0x00;
}
}
//-----------------------------------
//----------行扫描子程序-------------
void RowsCan(void)
{ uchar scan1;
if (i==0x08)
{
G1 = ! G1;i =0x00;
Huanping();
}
scan1 =i;
scan1 =scan1<<5;
P1 = P1 & 0x1f;
P1 = P1 | scan1;
i++;
}
void SendHang(void)
{
uchar m2;
for(m2 =0;m2<4;m2++)
{
SendData = data1[m1+m2];
SendByte();
}
for(m2 =0;m2<4;m2++)
{
SendData = data2[m1+m2];
SendByte();
}
for(m2 =0;m2<4;m2++)
{
SendData = data3[m1+m2];
SendByte();
}
for(m2 =0;m2<4;m2++)
{
SendData = data4[m1+m2];
SendByte();
}
SCK = 0;
SCK = 1;
RowsCan(); //行扫描
}
//---------------------------------------
//----------发送一屏数据-----------------
void Sendping(void)
{
SendHang();
m1 = m1+ 4;
if(m1 ==128) {m1 =0;}
}
void initial(void)
{
Gen1 = 1;
Gen2 = 0;
G1 = 0;
Red = 1;
Greed =1;
SendData = 0x00;
i = 0x00;
j = 0x00;
m1 = 0x00;
}
//;---------------------------------
//;---------主程序循环--------------
void main()
{
initial();
while(1)
{
Sendping();
}
}
[ 本帖最后由 wanchun311 于 2009-2-3 21:36 编辑 ]
附件
C语言实现汉字显示.JPG (20.68 KB)
2008-12-16 22:44
显示图片
LED点阵显示C程序和汇编程序.rar (3.4 KB)
2008-12-30 21:53, 下载次数: 16
LED点阵显示C程序和汇编程序
滚动显示4个汉字汇编程序.rar (2.23 KB)
2008-12-30 21:53, 下载次数: 13
滚动显示4个汉字汇编程序
引脚说明1.JPG (34.45 KB)
2009-2-3 21:33