新手上路:$
在网上淘了一块2手的点阵..
采用74HC595和74HC138的结构,电流驱动为TIP127. 8个io口控制..
只会写一个简单的静态显示.. 不懂写左右滚屏的程序..
请各位达人指点指点..:'(
本人真是菜到掉渣了..
静态程序如下:
#include "reg52.h"
#define uchar unsigned char
#define uint unsigned int
void Keyscan (void); //修改参数按键扫描子程序
void Sendping(); //发送半屏子程序
sbit CLK =P1^5 ; //74HC595移时钟
sbit STB =P1^4 ; // 74HC595锁存信号
sbit Red=P1^6 ; //红色数据输出引脚低电平有效
sbit Greed=P1^7; //全屏控制使能0,低电平有效
sbit OE = P0^7; //全屏使能
uchar SendData; //要发送的数据变量
uchar shuzu1; //数组一维变量
uchar shuzu2; //数组二维变量
uchar hang; //行扫描变量 (半屏只有16行,所以hang=0到15)
void delay()
{
uint i;
for(i=0;i<30;i++);
}
uchar code data1[8][32]=
{
{0x00,0x00,0x7F,0xFC,0x48,0x00,0x48,0x00,0x4F,0xF8,0x50,0x80,0x60,0x88,0x5F,0xFC
,0x41,0x40,0x41,0x20,0x42,0x10,0x44,0x18,0x48,0x10,0x40,0x00,0x7F,0xFE,0x00,0x00},
{0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00},
{0x06,0x08,0x78,0x88,0x08,0x48,0x08,0x48,0xFE,0x08,0x18,0x88,0x1C,0x48,0x2A,0x48,
0x28,0x0E,0x48,0x78,0x8B,0x88,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},
{0x20,0x40,0x20,0x40,0x20,0x40,0x23,0xF8,0xFC,0x48,0x20,0x48,0x22,0x48,0x22,0x4C,
0x24,0x8A,0x24,0x8A,0x20,0x88,0x21,0x08,0x21,0x08,0x22,0x28,0x24,0x10,0x00,0x00},
};
//------------------------------------
//----------字发送子程序-----------
void SendByte(void)
{
uchar m;
for(m=0;m<8;m++)
{
CLK = 0;
Red = (SendData & 0x80); //红屏显示
Greed = (SendData & 0x80); //红屏显示
SendData =SendData<<1;
CLK = 1; //移位时钟上升沿
}
}
//-----------------------------------
//----------行扫描子程序-------------
void RowsCan(void)
{
if (hang>=16)
{
hang =0x00;
}
P1 = P1 & 0xf0;
P1 = P1 | hang;
hang++;
}
void SendHang(void)
{
uchar m2,shuzu;
shuzu = shuzu1; //一维数组变量参数传给数组变量
OE=1;
for(m2 =0;m2<2;m2++)
{
SendData = data1[shuzu][shuzu2+m2];
SendByte();
}
shuzu++;
for(m2 =0;m2<2;m2++)
{
SendData = data1[shuzu][shuzu2+m2];
SendByte();
}
shuzu++;
for(m2 =0;m2<2;m2++)
{
SendData = data1[shuzu][shuzu2+m2];
SendByte();
}
shuzu++;
for(m2 =0;m2<2;m2++)
{
SendData = data1[shuzu][shuzu2+m2];
SendByte();
}
STB = 0;
STB = 1; //上升沿数据锁存
RowsCan(); //行扫描
OE = 0;
delay();
}
//---------------------------------------
//----------发送一屏数据-----------------
void Sendping(void)
{
SendHang();
shuzu2++ ;
shuzu2++ ;
if(shuzu2 ==32) { shuzu2 =0;}
}
void initial(void)
{
OE = 1;
Red = 1;
Greed = 1;
SendData = 0x00;
hang = 0x00;
}
//;---------主程序循环--------------
void main()
{
initial();
while(1)
{
Sendping();
}
} |