找回密码
 立即注册

QQ登录

只需一步,快速开始

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

流水灯显示学号

[复制链接]
跳转到指定楼层
楼主
ID:125403 发表于 2016-6-6 11:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/**********  hero lee编写,考试请勿直接移植,否则一切后果自负 **********/
/* 屏蔽的为清翔单片机开发板,若需使用则将没有屏蔽的注释,注释了的打开,*/
/*                学校发的开发板可直接修改学号数组下载                 */
/*    此程序须将开发板上的JOE排针上的跳线帽插左边两个即连接VCC与OE     */


/*
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int

uchar code display_lxy[20][8]={                                                                 //此数组为学号流动显示数码管代码
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,//       2
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,//      20
                                                0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,//     201
                                                0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,//    2013
                                                0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,//   20130
                                                0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,//  201306
                                                0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,// 2013060
                                                0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,//20130600
                                                0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,//01306002
                                                0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,//13060021
                                                0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,//30600210       
                                                0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,//06002107
                                                0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,//6002107
                                                0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,//002107
                                                0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,//02107
                                                0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,0x00,//2107
                                                0x06,0x3f,0x07,0x00,0x00,0x00,0x00,0x00,//107
                                                0x3f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,//07
                                                0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
                                            };                                                                                        //修改学号对应的数码管码
                                         //0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0~9

sbit we=P2^7;
sbit du=P2^6;

uchar ci=0,i,temp;

void init()                                                          //初始化
{
        TMOD=0x01;
        EA=1;
        ET0=1;      
        TH0=(65536-46082)/256;
        TL0=(65536-46082)%256;
        TR0=1;          
}

void delay_ms(uint z)                                  //毫秒级延时
{
        uint y;
        for(;z>0;z--)
                for(y=115;y>0;y--);
}

void main()
{
        init();
        while(1)
        {
                for (i=0;i<8;i++)
                {
                        P0=0;
                        du=1;
                        P0=0;  
                        du=0;

                        P0=0xff;       
                        we=1;
                        P0=_crol_(0xfe,i);
                        we=0;

                        P0=0;
                        du=1;
                        P0=display_lxy[ci][i];     //动态显示
                        du=0;
                        delay_ms(1);
            }
        }
}
void print() interrupt 1
{
        static uchar z=0;
        z++;
        if(z==10)
        {
                z=0;
                if (ci<19)
                        ci++;                                          //次数更新
                else
                        ci=0;
        }
        TH0=(65536-46082)/256;
        TL0=(65536-46082)%256;
}
*/

#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int

uchar code display_lxy[20][8]={                                                                 //此数组为学号流动显示数码管代码
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,//       2
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,//      20
                                                0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,//     201
                                                0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,//    2013
                                                0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,//   20130
                                                0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,//  201306
                                                0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,// 2013060
                                                0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,//20130600
                                                0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,//01306002
                                                0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,//13060021
                                                0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,//30600210
                                                0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,//06002107
                                                0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,//6002107
                                                0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,//002107
                                                0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,//02107
                                                0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,0x00,//2107
                                                0x06,0x3f,0x07,0x00,0x00,0x00,0x00,0x00,//107
                                                0x3f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,//07
                                                0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
                                                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
                                            };                                                                                        //修改学号对应的数码管码
                                         //0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0~9

sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4;                                                //端口定义

uchar ci=0,i,temp;

void init()                                                          //初始化
{
        TMOD=0x01;
        EA=1;
        ET0=1;      
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
        TR0=1;          
}

void delay_ms(uint z)                                  //毫秒级延时
{
        uint y;
        for(;z>0;z--)
                for(y=125;y>0;y--);
}

void display()
{
        P0=0; c=0;b=0;a=0; P0=display_lxy[ci][7]; delay_ms(1);
        P0=0; c=0;b=0;a=1; P0=display_lxy[ci][6]; delay_ms(1);
        P0=0; c=0;b=1;a=0; P0=display_lxy[ci][5]; delay_ms(1);
        P0=0; c=0;b=1;a=1; P0=display_lxy[ci][4]; delay_ms(1);
        P0=0; c=1;b=0;a=0; P0=display_lxy[ci][3]; delay_ms(1);
        P0=0; c=1;b=0;a=1; P0=display_lxy[ci][2]; delay_ms(1);
        P0=0; c=1;b=1;a=0; P0=display_lxy[ci][1]; delay_ms(1);
        P0=0; c=1;b=1;a=1; P0=display_lxy[ci][0]; delay_ms(1);
}
void main()
{
        init();
        while(1)
                display();
}
void print() interrupt 1
{
        static uchar z=0;
        z++;
        if(z==10)
        {
                z=0;
                if (ci<19)
                        ci++;                                          //次数更新
                else
                        ci=0;
        }
        TH0=(65536-50000)/256;
        TL0=(65536-50000)%256;
}


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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