点阵显示心型
Posted 荆紫藤
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了点阵显示心型相关的知识,希望对你有一定的参考价值。
心形图案
#include<reg52.h>
//绑定位
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char code LedChar[] = { //点阵显示字符转换表
0xff,0x99,0x00,0x00,0x00,0x81,0xc3,0xe7//实心
//空心(0x99,0x66,0x7E,0x7E,0xBD,0xDB,0xE7,0xFF),case 7:需注释
};
void main(){
EA=1;
ADDR3=0; //使能U4
ENLED=0;
TMOD=0x01; //使能T0为模式1
TH0=0xFC; // 为T0赋初始值
TL0=0x67;
ET0=1; //使能中断
TR0=1; //开启T0
while(1);
}
/**
中断处理
*/
void InterRupt() interrupt 1{
static unsigned char i=0;
TH0=0xfc;
TL0=0x67;
P0=0xff;//清屏
switch(i){//点阵显示循环图案部分
case 0: ADDR2 = 0; ADDR1 = 0; ADDR0 = 0; i++; P0=LedChar[0]; break;
case 1: ADDR2 = 0; ADDR1 = 0; ADDR0 = 1; i++; P0=LedChar[1]; break;
case 2: ADDR2 = 0; ADDR1 = 1; ADDR0 = 0; i++; P0=LedChar[2]; break;
case 3: ADDR2 = 0; ADDR1 = 1; ADDR0 = 1; i++; P0=LedChar[3]; break;
case 4: ADDR2 = 1; ADDR1 = 0; ADDR0 = 0; i++; P0=LedChar[4]; break;
case 5: ADDR2 = 1; ADDR1 = 0; ADDR0 = 1; i++; P0=LedChar[5]; break;
case 6: ADDR2 = 1; ADDR1 = 1; ADDR0 = 0; i++; P0=LedChar[6]; break;
case 7: ADDR2 = 1; ADDR1 = 1; ADDR0 = 1; i=0; P0=LedChar[7]; break;
}
}
以上是关于点阵显示心型的主要内容,如果未能解决你的问题,请参考以下文章