找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3482|回复: 3
收起左侧

8×8LED点阵屏仿电梯数字滚动显示单片机C程序

[复制链接]
ID:234873 发表于 2018-12-24 11:00 | 显示全部楼层 |阅读模式
#include<reg52.h>
#include<absacc.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*-------------------------------------------------------
功能:5*7点阵表
----------------------------------------------------------*/
uchar code biao[11][8]=
{
{0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x00}, // -0-
{0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00}, // -1-
{0x70,0x88,0x08,0x30,0x40,0x80,0xF8,0x00}, // -2-
{0xF8,0x08,0x10,0x30,0x08,0x88,0x70,0x00}, // -3-
        {0x10,0x30,0x50,0x90,0xF8,0x10,0x10,0x00}, // -4-
        {0xF8,0x80,0xF0,0x08,0x08,0x88,0x70,0x00}, // -5-
        {0x38,0x40,0x80,0xF0,0x88,0x88,0x70,0x00}, // -6-
     {0xF8,0x08,0x10,0x20,0x40,0x40,0x40,0x00}, // -7-
     {0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00}, // -8-
     {0x70,0x88,0x88,0x78,0x08,0x10,0xE0,0x00}, // -9-
     {0x20,0x70,0xa8,0x20,0x20,0x20,0x20,0x00}  // -↑-
};
/*-------------------------------------------------------
功能:扫描表
----------------------------------------------------------*/
//uchar code sao[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code sao[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
/*-------------------------------------------------------
功能:串口初始化,波特率9600 方式0 8 UART
-------------------------------------------------------*/
void Init_Com(void)
{
     SCON = 0x00; //方式0  

}
/*-------------------------------------------------------
功能:延时
-------------------------------------------------------*/
//1
void DELAY_25mS(void)
{
   unsigned int x = 45438;
   while (--x)
   {
      _nop_();
   }
}
//2
delay(uchar ms)
{       // 延时子程序
uchar  i;
while(ms--)
{
  for(i = 0; i<250; i++)
  {
   _nop_();
   _nop_();
   _nop_();
   _nop_();
  }
}
}
//3
delay1(t)
{
   while(t--)
   {
     ;
   }
}
/*-------------------------------------------------------
功能:显示子程序
-------------------------------------------------------*/
xian()
{
uchar a;
for(a=0;a<8;a++)
      {
        SBUF =biao[0][a]; //串口发第一个显示字
while(!TI);
     TI=0;
     SBUF =biao[1][a]; //串口发第二个显示字
while(!TI);
     TI=0;
     SBUF =biao[3][a]; //串口发第三个显示字
while(!TI);
     TI=0;
     P1=sao[a]; //
        delay1(100);
        P1=0xff;
       }
}
/*-------------------------------------------------------
主程序
功能:实现接收数据并把接收到的数据发送出去
-------------------------------------------------------*/
void main()
{
   uchar ii;
   Init_Com();
    //SBUF = dis_7[0];   //发送数据
//while(!TI);
     //TI=0;
   while(1)
   {   
    xian();
   }
}
回复

使用道具 举报

ID:1 发表于 2018-12-24 16:25 | 显示全部楼层
补全原理图或者详细说明一下电路连接即可获得100+黑币
回复

使用道具 举报

ID:424598 发表于 2018-12-24 16:44 | 显示全部楼层
代码中没看到io口定义,一堆头文件,楼主却没有上传附件
回复

使用道具 举报

ID:383832 发表于 2020-10-16 21:29 | 显示全部楼层
乱写一通
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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