新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 點(diǎn)陣流水顯示I_LOVE_YOU

點(diǎn)陣流水顯示I_LOVE_YOU

作者: 時(shí)間:2016-11-20 來(lái)源:網(wǎng)絡(luò) 收藏


* 功 能:點(diǎn)陣流水顯示I_LOVE_YOU *
* 時(shí)鐘頻率:內(nèi)部4M *
* 編譯環(huán)境: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,}; //顯示數(shù)據(jù)

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; //時(shí)鐘0和時(shí)鐘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) //將顯示的數(shù)據(jù)送入緩沖數(shù)組
{
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;
}
}



關(guān)鍵詞: 點(diǎn)陣流水顯

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉