微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 点阵流水显示I_LOVE_YOU

点阵流水显示I_LOVE_YOU

时间:11-20 来源:互联网 点击:


* 功 能:点阵流水显示I_LOVE_YOU *
* 时钟频率:内部4M *
* 编译环境:ICC-AVR7.22 *
* 版本:1.0 *

#include
#include
#define uint unsigned int
#define uchar unsigned char
#define OE_138_ON PORTC |= (1 //使能74hc138
#define OE_138_OFF PORTC &= ~(1#define array_size 63

const uchar I_LOVE_YOU[]={0X00,0X44,0X44,0X7C,0X44,0X44,0X00,0X00,
0X44,0X7C,0X44,0X40,0X40,0X40,0X40,0X00,
0X38,0X44,0X44,0X44,0X44,0X44,0X38,0X00,
0X04,0X0C,0X34,0X40,0X20,0X1C,0X0C,0X04,
0X44,0X7C,0X4C,0X4C,0X5C,0X44,0X44,0X00,
0X04,0X0C,0X4C,0X74,0X4C,0X0C,0X04,0X00,
0X04,0X7C,0X44,0X40,0X40,0X44,0X7C,0X04
0X38,0X44,0X44,0X44,0X44,0X44,0X38,0X00,}; //显示数据

const uchar seg[]={0,1,2,3,4,5,6,7}; //选通位码
uchar buffer[]={0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00};

void main(void)
{
DDRA=0xFF;
PORTA=0xFF;
DDRB=0xFF;
PORTB=0xFF;
DDRC=0x80;
TCCR0=0X0D;
TCNT0=0X00;
OCR0=8;
TIMSK|=0X02;
TIFR|=0X02;
TCCR1A=0X00;
TCCR1B=0X0D;
OCR1A=2500;
TIMSK|=0X10;
TIFR|=0X10; //时钟0和时钟1的初始化,CTC模式
OE_138_ON;
SEI();
while(1)
{
};
}

uchar count=0;
uchar j=0;

#pragma interrupt_handler time0:20 time1:7
void time0(void) //选通显示的位置
{
PORTB=buffer[j];
PORTA=seg[j];
j++;
if(j==8)
{
j=0;
}
}

void time1(void) //将显示的数据送入缓冲数组
{
uchar i;
for(i=0;i<7;i++)
{
buffer[i]=buffer[i+1];
}
buffer[7]=I_LOVE_YOU[count];
count++;
if(count==array_size)
{
count=0;
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top