找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1509|回复: 9
打印 上一主题 下一主题
收起左侧

求助单片机点阵显示表情发暗原因

[复制链接]
跳转到指定楼层
楼主
ID:405030 发表于 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
只写了一部分
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:522756 发表于 2020-8-11 10:02 | 只看该作者
两个点
①驱动电压不足
②你程序里面刷新的时间太慢了,导致显示的很暗
回复

使用道具 举报

板凳
ID:701852 发表于 2020-8-11 15:41 | 只看该作者
刷新太快也有可能
回复

使用道具 举报

地板
ID:405030 发表于 2020-8-11 21:09 | 只看该作者
世界太小_ 发表于 2020-8-11 10:02
两个点
①驱动电压不足
②你程序里面刷新的时间太慢了,导致显示的很暗

谢谢了
回复

使用道具 举报

5#
ID:813417 发表于 2020-8-12 09:19 | 只看该作者
电阻减少一点
回复

使用道具 举报

6#
ID:235954 发表于 2020-8-12 11:15 | 只看该作者
刷新频率过低,用51单片机的时候,刷新频率给低也是会变暗
回复

使用道具 举报

7#
ID:813542 发表于 2020-8-12 14:40 | 只看该作者
频率太慢了
回复

使用道具 举报

8#
ID:809311 发表于 2020-8-12 14:43 | 只看该作者
要写调亮度的代码进去。
回复

使用道具 举报

9#
ID:74382 发表于 2020-8-14 21:19 | 只看该作者
有源码和电路图吗
回复

使用道具 举报

10#
ID:74382 发表于 2020-8-14 21:24 | 只看该作者
源码和电路图呢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表