打印

【转】基于AT89S52单片机的可控点阵

[复制链接]
837|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
南国先生|  楼主 | 2017-1-4 12:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

  一段时间没有更新博客了,最近忙着给别人做项目呢,说来还有点不好意思,我所说的项目是给大四的毕业生做毕业设计,但我相信这是第一步,以后我也可以进行工业项目的研发的。

      昨天成功交了一个活儿,拿到了700块钱,真心心情不错。今天是五一劳动节,室友们都出去玩儿了,其实我也挺想出去逛逛的,不是为了玩,是为了见见世面,可是我现在的情况真的不适合,也没有钱,这几天我把节奏放慢了一点,看看电影,听听歌,写写博客,好好睡个觉,也挺好。每次写博客之前我总是唠叨一下自己,是一种倾诉吧,也是一种自我鼓励,,,

     不想写什么原理之类的了,太大陆货儿了,只是把原理图,和程序传上来,让如果想做类似东西的朋友们参考一下吧。

       要求(老板要求实现的功能):

有3个控制按键:K1,模式选择键;   K2,增速键;K3,减速键。
    增速与减速模式,各要有至少3种,(包括原档位,共4种档位)即:按一下K2,速度增加,再按下K2,增速继续增加,再按下K2,增速继续增加;按一下K3,速度减少,再按下K3,速度继续减少,再按下K3,速度继续减少。

    各种模式要类似广告流水灯,是从8*8点阵左→右移动,速度是指左→右的移动速度。
    8种模式的内容要不相同。
      如:
                   模式一  实现正向流动显示 eec fly;
          模式二:实现反向流动显示 eec fly;
          模式三:数字顺序显示 1 2 3 4 5;
          模式四:字母顺序显示,A  B  C  D  E;
          模式五:花样灯1;(图形1)
          模式六:花样灯2,(图形2)   

      事物照片:


      原理图:


      程序:

#include<reg51.h>
unsigned char code tab_zuo[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};    //从左往右
unsigned char code tab_you[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};     //从右往左
unsigned char code tab[8]={~0x3f,~0x06,~0x5b,~0x4f,~0x66,~0x6d,~0x7d,~0x07,};   //共阳数码管字模
int mode_data=0,add_data=7;

sbit key1=P3^2;
sbit key2=P3^3;
sbit key3=P3^4;

unsigned char code shuzu_1[]={
0x00,0x01,0x7f,0x21,0x00,0x00,0x00,0x00,    //1
0x00,0x39,0x45,0x45,0x45,0x27,0x00,0x00,    //2
0x00,0x36,0x49,0x49,0x49,0x22,0x00,0x00,    //3
0x00,0x04,0x7f,0x24,0x14,0x0c,0x00,0x00,    //4
0x00,0x4e,0x51,0x51,0x51,0x72,0x00,0x00,    //5
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code shuzu_2[]={
0x00,0x0e,0x34,0x44,0x44,0x34,0x0e,0x00,   //A
0x00,0x00,0x3c,0x4a,0x4a,0x4a,0x7e,0x00,   //B
0x00,0x00,0x62,0x41,0x41,0x3e,0x00,0x00,   //C
0x00,0x00,0x3c,0x42,0x42,0x42,0x7e,0x00,   //D
0x00,0x00,0x49,0x49,0x49,0x7f,0x00,0x00,   //E
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code shuzu_3 []={
0x00,0x08,0x1c,0x08,0x08,0x08,0x08,0x00,
0x00,0x08,0x1c,0x08,0x08,0x08,0x08,0x00,
0x00,0x08,0x1c,0x08,0x08,0x08,0x08,0x00,
0x00,0x08,0x1c,0x08,0x08,0x08,0x08,0x00,
0x00,0x08,0x1c,0x08,0x08,0x08,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};
unsigned char code shuzu_4[]={
0x70,0x8c,0x42,0x21,0x21,0x42,0x8c,0x70,
0x70,0x8c,0x42,0x21,0x21,0x42,0x8c,0x70,
0x70,0x8c,0x42,0x21,0x21,0x42,0x8c,0x70,
0x70,0x8c,0x42,0x21,0x21,0x42,0x8c,0x70,
0x70,0x8c,0x42,0x21,0x21,0x42,0x8c,0x70,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code shuzu_5[]={
0x00,0x00,0x32,0x52,0x52,0x3c,0x00,0x00, // e          //从左往右
0x00,0x00,0x32,0x52,0x52,0x3c,0x00,0x00, // e
0x00,0x00,0x42,0x42,0x42,0x7e,0x00,0x00, // c
0x00,0x00,0x00,0x40,0x50,0x3e,0x10,0x00, // f
0x00,0x00,0x04,0x02,0x7e,0x00,0x00,0x00, // l
0x00,0x00,0x7e,0x09,0x09,0x71,0x00,0x00, // y
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code shuzu_6[]={
0x00,0x00,0x3C,0x52,0x52,0x32,0x00,0x00, // e
0x00,0x00,0x3C,0x52,0x52,0x32,0x00,0x00, // e
0x00,0x00,0x7E,0x42,0x42,0x42,0x00,0x00, // c
0x00,0x10,0x3E,0x50,0x40,0x00,0x00,0x00, // f
0x00,0x00,0x00,0x7e,0x02,0x04,0x00,0x00, // l
0x00,0x00,0x71,0x09,0x09,0x7E,0x00,0x00, // y
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
unsigned char code shuzu_7[]={
0x10,0x08,0x04,0x08,0x10,0x20,0x10,0x08,
0x10,0x08,0x04,0x08,0x10,0x20,0x10,0x08,
0x10,0x08,0x04,0x08,0x10,0x20,0x10,0x08,
0x10,0x08,0x04,0x08,0x10,0x20,0x10,0x08,
0x10,0x08,0x04,0x08,0x10,0x20,0x10,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char code shuzu_8[]={
0x14,0x04,0x10,0x14,0x04,0x10,0x14,0x04,
0x14,0x04,0x10,0x14,0x04,0x10,0x14,0x04,
0x14,0x04,0x10,0x14,0x04,0x10,0x14,0x04,
0x14,0x04,0x10,0x14,0x04,0x10,0x14,0x04,
0x14,0x04,0x10,0x14,0x04,0x10,0x14,0x04,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
//函数声明
void show();
void mode (int s,int t);
int v_add();


void delay(unsigned int t)
{
   while (t--)
        {;}
}
void delay_us(int x)
{
int a,b;
for(a=x;a>0;a--)
  for(b=110;b>0;b--);

}


void main(void)
{  
       while(1)
{
P3 = 0XFF;
show();
      
}

}


void show()
{
  unsigned int i,j,a;
  for(i=0;i<=40;i++)   //循环扫描一遍40帧
  {
     for(a=0;a<10*v_add();a++)  //移动速度
      {
    for(j=0;j<=7;j++)
       {
     
      mode ((i+j),j);//模式
      
                  delay(50);
    }
    }
  }
}
void mode (int s,int t)//模式
{
if(key1==0)
{
delay_us(10);
if(key1==0)
mode_data++;
while(!key1);
delay_us(10);
while(!key1);
}
if(mode_data >7)
mode_data = 0;

switch(mode_data)
{
  case 0 : P1=shuzu_1; P2=tab_zuo[t]; P0=tab[0]; break;
  case 1 : P1=shuzu_2; P2=tab_zuo[t]; P0=tab[1]; break;
  case 2 : P1=shuzu_3; P2=tab_zuo[t]; P0=tab[2]; break;
  case 3 : P1=shuzu_4; P2=tab_zuo[t]; P0=tab[3]; break;
  case 4 : P1=shuzu_5; P2=tab_zuo[t]; P0=tab[4]; break;
  case 5 : P1=shuzu_6; P2=tab_you[t]; P0=tab[5]; break;
  case 6 : P1=shuzu_7; P2=tab_zuo[t]; P0=tab[6]; break;
  default : P1=shuzu_8; P2=tab_zuo[t]; P0=tab[7]; break;
}
  
}
int v_add()//速度加 ; 速度减
{
//速度加
if(key2==0)
{
delay_us(10);
if(key2==0)
add_data = add_data+2;
while(!key2);
delay_us(10);
while(!key2);
}

//速度减
if(key3==0)
{
delay_us(10);
if(key3==0)
add_data = add_data-2;
while(!key3);
delay_us(10);
while(!key3);
}
if(add_data<0)
add_data = 7;
return add_data;
}



相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

68

主题

160

帖子

3

粉丝