写一个keil点阵显示at89c52的程序
时间: 2023-09-06 08:12:17 浏览: 146
下面是一个基本的 Keil 点阵显示程序,用于 AT89C52 微控制器:
```c
#include <reg52.h>
//定义点阵字体数组
unsigned char code font[16][16]={
{0x00,0x3c,0x42,0x99,0xa5,0xa5,0x99,0x42,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//A
{0x00,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//B
{0x00,0x7e,0x81,0x81,0x81,0x81,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//C
{0x00,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//D
{0x00,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//E
{0x00,0xff,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//F
{0x00,0x7e,0x81,0x81,0x81,0x81,0x91,0x91,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//G
{0x00,0xff,0x08,0x08,0x08,0x08,0x08,0x08,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//H
{0x00,0x81,0x81,0x81,0xff,0x81,0x81,0x81,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//I
{0x00,0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//J
{0x00,0xff,0x08,0x14,0x22,0x41,0x81,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//K
{0x00,0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//L
{0x00,0xff,0x02,0x0c,0x30,0x30,0x0c,0x02,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//M
{0x00,0xff,0x02,0x0c,0x10,0x20,0x40,0x80,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//N
{0x00,0x7e,0x81,0x81,0x81,0x81,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//O
{0x00,0xff,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}//P
};
//延时函数
void delay(unsigned int ms)
{
unsigned int x, y;
for(x = ms; x > 0; x--)
for(y = 110; y > 0; y--);
}
void main()
{
unsigned char i,j,k;
while(1)
{
for(i=0;i<16;i++)
{
for(j=0;j<8;j++)
{
for(k=0;k<16;k++)
{
P2=0x01<<j;
P0=~font[i][k];
delay(2);
}
}
}
}
}
```
这个程序使用了一个 `font` 数组,其中存储了 16 个字符的点阵数据。在主函数中,程序循环显示每个字符的点阵图案,并使用延时函数来控制点阵的刷新速度。请注意,这个程序只是基本的示例代码,您可能需要根据您的具体应用进行修改和优化。
阅读全文