昨天晚上弄懂了8×8点阵的原理,今天晚上我自己拿点阵模子,设计了个“♥”形的显示效果,于是开始写代码调试,最后终于弄出来了,效果图如下:
8×8点阵显示原理,类似于点阵矩形键盘的原理,只要由DIOLA锁存端控制了高电平,然后DULA锁存端控制了低电平,那么电流由高到低就形成了回路,于是发光二极管就会点亮。
我的开发板的原理图如下:
源代码如下:
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula = P2 ^ 6;
sbit diola = P2 ^ 5;
sbit wela = P2 ^ 7;
void delay(uint time)
{
uint x, y;
for (x = time; x > 0; x--)
for (y = 110; y > 0; y--);
}
void close_shuma()
{
wela = 1;
delay(10);
P0 = 0xff;
delay(10);
wela = 0;
delay(10);
}
void init_led()
{
dula = 1;
diola = 1;
P0 = 0x00;
dula = 0;
diola = 0;
delay(1);
}
void display()
{
//1
init_led();
dula = 1;
P0 = 0xff;
dula = 0;
diola = 1;
P0 = 0x01;
diola = 0;
delay(3);
//2
init_led();
dula = 1;
P0 = 0x99;
dula = 0;
diola = 1;
P0 = 0x02;
diola = 0;
delay(3);
//3
init_led();
dula = 1;
P0 = 0x00;
dula = 0;
diola = 1;
P0 = 0x04;
diola = 0;
delay(3);
//4
init_led();
dula = 1;
P0 = 0x00;
dula = 0;
diola = 1;
P0 = 0x08;
diola = 0;
delay(3);
//5
init_led();
dula = 1;
P0 = 0x81;
dula = 0;
diola = 1;
P0 = 0x10;
diola = 0;
delay(3);
//6
init_led();
dula = 1;
P0 = 0x81;
dula = 0;
diola = 1;
P0 = 0x20;
diola = 0;
delay(3);
//7
init_led();
dula = 1;
P0 = 0xc3;
dula = 0;
diola = 1;
P0 = 0x40;
diola = 0;
delay(3);
//8
init_led();
dula = 1;
P0 = 0xe7;
dula = 0;
diola = 1;
P0 = 0x80;
diola = 0;
delay(3);
}
void main()
{
close_shuma();
while (1) {
display();
}
}
文章的脚注信息由WordPress的wp-posturl插件自动生成




微信扫一扫,打赏作者吧~![[整理]三极管驱动继电器](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2014/02/11.jpg&w=280&h=210&zc=1)


