标题:
求助单片机点阵显示表情发暗原因
[打印本页]
作者:
yu1994
时间:
2020-8-10 21:08
标题:
求助单片机点阵显示表情发暗原因
#include<reg52.h>
sbit a=P0^0;
sbit b=P0^1;
sbit c=P0^2;
sbit OE0=P0^3;
sbit OE1=P0^4;
sbit OE2=P0^5;
sbit KEY1=P3^2;
sbit KEY2=P3^3;
sbit KEY3=P3^4;
sbit KEY4=P3^5;
unsigned char code LedChar[7][8]={
{0xC3,0x81,0x00,0x00,0x00,0x81,0xFF,0xFF},
{0xFF,0x81,0x00,0x00,0x00,0x81,0xFF,0xFF},
{0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF},
{0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF}, //不按按键时
{0xEF,0xDF,0xBF,0x00,0xBF,0xDF,0xEF,0xFF}, //左转
{0xF7,0xFB,0xFD,0x00,0xFD,0xFB,0xF7,0xFF}, //右转
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x66,0x99}, //W
};
void buan(); //不按按键函数
void ting(); //刹车时函数
void you(); //左转时函数
void zuo(); //右转时函数
void main()
{
while(1)
{
if(KEY1==0)
{
you();
}
else if(KEY2==0)
{
zuo();
}
else
{
buan();
}
}
}
/*不按按键*/
void buan()
{
static unsigned char cnt1=0;
static unsigned char d=0;
static unsigned int tmr=0;
static unsigned char i=0;
P1=0xFF;
switch(i)
{
case 0:a=0;b=0;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][0];break;
case 1:a=0;b=0;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][1];break;
case 2:a=0;b=1;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][2];break;
case 3:a=0;b=1;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][3];break;
case 4:a=1;b=0;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][4];break;
case 5:a=1;b=0;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][5];break;
case 6:a=1;b=1;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][6];break;
case 7:a=1;b=1;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[cnt1][7];break;
case 8:a=0;b=0;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][0];break;
case 9:a=0;b=0;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][1];break;
case 10:a=0;b=1;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][2];break;
case 11:a=0;b=1;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][3];break;
case 12:a=1;b=0;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][4];break;
case 13:a=1;b=0;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][5];break;
case 14:a=1;b=1;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][6];break;
case 15:a=1;b=1;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][7];break;
case 16:a=0;b=0;c=0;OE0=1;OE1=1;OE2=1;i++;P1=LedChar[cnt1][0];break;
case 17:a=0;b=0;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][1];break;
case 18:a=0;b=1;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][2];break;
case 19:a=0;b=1;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][3];break;
case 20:a=1;b=0;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][4];break;
case 21:a=1;b=0;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][5];break;
case 22:a=1;b=1;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[cnt1][6];break;
case 23:a=1;b=1;c=1;OE0=1;OE1=1;OE2=0;i=0;P1=LedChar[cnt1][7];break;
default:break;
}
for(d=0;d>50;d++);
tmr++;
if(tmr>=500)
{
tmr=0;
cnt1++;
if(cnt1>=4)
{
cnt1=0;
}
}
}
/*右转*/
void you()
{
static unsigned char i=0;
P1=0xFF;
switch(i)
{
case 0:a=0;b=0;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][0];break;
case 1:a=0;b=0;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][1];break;
case 2:a=0;b=1;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][2];break;
case 3:a=0;b=1;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][3];break;
case 4:a=1;b=0;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][4];break;
case 5:a=1;b=0;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][5];break;
case 6:a=1;b=1;c=0;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][6];break;
case 7:a=1;b=1;c=1;OE0=0;OE1=1;OE2=1;i++;P1=LedChar[5][7];break;
case 8:a=0;b=0;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][0];break;
case 9:a=0;b=0;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][1];break;
case 10:a=0;b=1;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][2];break;
case 11:a=0;b=1;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][3];break;
case 12:a=1;b=0;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][4];break;
case 13:a=1;b=0;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][5];break;
case 14:a=1;b=1;c=0;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][6];break;
case 15:a=1;b=1;c=1;OE0=1;OE1=0;OE2=1;i++;P1=LedChar[6][7];break;
case 16:a=0;b=0;c=0;OE0=1;OE1=1;OE2=1;i++;P1=LedChar[5][0];break;
case 17:a=0;b=0;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][1];break;
case 18:a=0;b=1;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][2];break;
case 19:a=0;b=1;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][3];break;
case 20:a=1;b=0;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][4];break;
case 21:a=1;b=0;c=1;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][5];break;
case 22:a=1;b=1;c=0;OE0=1;OE1=1;OE2=0;i++;P1=LedChar[5][6];break;
case 23:a=1;b=1;c=1;OE0=1;OE1=1;OE2=0;i=0;P1=LedChar[5][7];break;
default:break;
}
}
芯片使用的是74h138
只写了一部分
作者:
世界太小_
时间:
2020-8-11 10:02
两个点
①驱动电压不足
②你程序里面刷新的时间太慢了,导致显示的很暗
作者:
13487086265
时间:
2020-8-11 15:41
刷新太快也有可能
作者:
yu1994
时间:
2020-8-11 21:09
世界太小_ 发表于 2020-8-11 10:02
两个点
①驱动电压不足
②你程序里面刷新的时间太慢了,导致显示的很暗
谢谢了
作者:
mirror.
时间:
2020-8-12 09:19
电阻减少一点
作者:
梁廷明
时间:
2020-8-12 11:15
刷新频率过低,用51单片机的时候,刷新频率给低也是会变暗
作者:
ngp123235
时间:
2020-8-12 14:40
频率太慢了
作者:
Roy-2010
时间:
2020-8-12 14:43
要写调亮度的代码进去。
作者:
qiuge
时间:
2020-8-14 21:19
有源码和电路图吗
作者:
qiuge
时间:
2020-8-14 21:24
源码和电路图呢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1