对应硬件系统:恒坚电器-AVR-C51综合学习板
单片机类型:C51
开发环境:keil C
以下是恒坚电子的网站:http://www.hejoin.com/
程序是我很早以前写的.仅做为参考学习..
#include <at89x51.H>
const char mytext[][8]={{0xF9,0xF9,0xF9,0xF9,0xF9,0xF9,0x81,0x81},//L
{0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7,0xC3},//I
{0x81,0x81,0xE7,0xE7,0xE4,0xE4,0xE1,0xF3},//J
{0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xE7,0xC3},//I
{0x3C,0x3C,0x38,0x30,0x24,0x0C,0x1C,0x3C},//N
{0x99,0x99,0x99,0x81,0x81,0x99,0x99,0x99},//H
{0xC3,0x99,0x99,0x81,0x81,0x99,0x99,0x99},//A
{0xC3,0x99,0x99,0x99,0x99,0x99,0x99,0xC3}//O
};
//1~8号LED数据管地址号或点阵中的行号
const char Led[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
/*单位输出
showbit:选择输出的LED管子
LedNum:要输出的数据
*/
void delay(unsigned char times)
{
//不精确延时,误差很大
unsigned char i;
for(;times>0;times--)
for(i=0;i<255;i--);
}
void display(unsigned char showbit,LedText)
{
P2_7=0;//片选
P0=Led[showbit-1]; //给P2_6一个脉冲选择在哪一行上显示
P2_6=1;
P2_6=0;
//-------------
P0=LedText;//给P2_5一个脉冲,将要显示的数据显示缓冲区中
P2_5=1;
P2_5=0;
}
//-----------------------------------
void ShowArray(unsigned char iRow)
{
unsigned char iCol=0;
int sc=0;
for(;sc<=3000;sc++)//加循环是为了让个点阵字多显示一会儿
{
if (iCol==8) iCol=0;
display(iCol+1,mytext[iRow][iCol]);
delay(20);
iCol++;
}
}
//------------------
void main(void)
{
unsigned char iRow=0;
while(1)
{
if(iRow==8) iRow=0;
ShowArray(iRow);
delay(2000);
delay(2000);
delay(2000);
iRow++;//选择下一个要显示的字模
}
}