新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)驅(qū)動(dòng)點(diǎn)陣16*16綜合C程序-包含各種效果

單片機(jī)驅(qū)動(dòng)點(diǎn)陣16*16綜合C程序-包含各種效果

作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
一、硬件簡(jiǎn)介: 經(jīng)過努力,終于完成了我以前一直的夢(mèng)想,點(diǎn)陣各種模式能獨(dú)立原創(chuàng)出點(diǎn)陣屏各種模式:間斷、上移、下移、左移、右移、上拉幕、下拉幕、左拉幕、右拉幕、左覆蓋、右覆蓋等等模式,我認(rèn)為點(diǎn)陣只要是上移、左移會(huì)了,基本其它的都會(huì)了!一定要理解了,才算喲,太高興了,現(xiàn)在和大家分享下了,我的硬件是:行是譯碼器74HC154+S8550,列是74HC595移位寄存器.


祥細(xì)視頻如下http://www.tudou.com/programs/view/D0SCJyO4RBQ/ 
完整的程序源代碼下載:http://www.51hei.com/f/dz854.rar

本文引用地址:http://m.butianyuan.cn/article/201611/323390.htm

二、具體原理圖見

電路介紹:http://www.51hei.com/mcu/1523.html

三、具體程序代碼如下:

#include

#define uchar unsigned char

#define uint unsigned int

#define LINE P0//定義行線IO口,即74HC154控制端

#define shudu 12//字移動(dòng)的速度

sbit DATA=P1^4;//74HC595數(shù)據(jù)端

sbit CLK=P1^5;//74HC595移位脈沖端

sbit CLKR=P1^6;//74HC595數(shù)據(jù)鎖存端

uchar move;//移動(dòng)幾位變量

uchar line;//行變量

uint word;//字節(jié)變量

uchar ji,gai;//字節(jié)變量

uchar BUF[4];//4組緩存數(shù)組以便左移右移等功能動(dòng)態(tài)更改數(shù)據(jù)

/************************************************************/

/**********上移上拉左移左拉左覆蓋數(shù)組************************/

/************************************************************/

uchar code table[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x10,0x3F,0xF8,0x04,0x10,0x04,0x14,0xFF,0xFE,0x04,0x10,0x04,0x10,

0x3F,0xF0,0x04,0x10,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,

0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x10,

0x1F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x50,0x10,0x20,

0x01,0x10,0xFF,0x90,0x14,0x50,0x14,0x7C,0x7F,0x50,0x55,0x90,0x55,0x10,0x57,0xFE,

0x61,0x04,0x41,0x7E,0x41,0x44,0x7F,0x44,0x41,0x44,0x41,0x44,0x7F,0x7C,0x41,0x44,

0x00,0x78,0x3F,0x80,0x11,0x10,0x09,0x20,0x7F,0xFE,0x42,0x02,0x82,0x04,0x7F,0xF8,

0x04,0x00,0x07,0xF0,0x0A,0x20,0x09,0x40,0x10,0x80,0x11,0x60,0x22,0x1C,0x0C,0x08,

0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x08,0x7C,0x09,0x44,0x7F,0xC4,0x08,0x7C,

0x0A,0x44,0x3F,0x44,0x22,0x7C,0x22,0x44,0x22,0x44,0x3E,0x44,0x22,0x94,0x01,0x08,

0x08,0x20,0x08,0x24,0xFF,0xFE,0x08,0x20,0x01,0x08,0x3F,0xFC,0x20,0x08,0x20,0x08,

0x3F,0xF8,0x20,0x08,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,

0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x20,0x10,0x20,0x22,0x44,0x7E,0xFC,0x04,0x08,

0x08,0x10,0x10,0x20,0x20,0x40,0x7E,0xFC,0x00,0x00,0x00,0x04,0xFF,0xFE,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

};

/************************************************************/

/**********************下拉、下移數(shù)組************************/

/************************************************************/

uchar code table1[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x20,0x10,0x20,0x22,0x44,0x7E,0xFC,0x04,0x08,

0x08,0x10,0x10,0x20,0x20,0x40,0x7E,0xFC,0x00,0x00,0x00,0x04,0xFF,0xFE,0x00,0x00,

0x08,0x20,0x08,0x24,0xFF,0xFE,0x08,0x20,0x01,0x08,0x3F,0xFC,0x20,0x08,0x20,0x08,

0x3F,0xF8,0x20,0x08,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,

0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x08,0x7C,0x09,0x44,0x7F,0xC4,0x08,0x7C,

0x0A,0x44,0x3F,0x44,0x22,0x7C,0x22,0x44,0x22,0x44,0x3E,0x44,0x22,0x94,0x01,0x08,

0x00,0x78,0x3F,0x80,0x11,0x10,0x09,0x20,0x7F,0xFE,0x42,0x02,0x82,0x04,0x7F,0xF8,

0x04,0x00,0x07,0xF0,0x0A,0x20,0x09,0x40,0x10,0x80,0x11,0x60,0x22,0x1C,0x0C,0x08,

0x01,0x10,0xFF,0x90,0x14,0x50,0x14,0x7C,0x7F,0x50,0x55,0x90,0x55,0x10,0x57,0xFE,

0x61,0x04,0x41,0x7E,0x41,0x44,0x7F,0x44,0x41,0x44,0x41,0x44,0x7F,0x7C,0x41,0x44,

0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x10,

0x1F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x50,0x10,0x20,

0x00,0x00,0x00,0x10,0x3F,0xF8,0x04,0x10,0x04,0x14,0xFF,0xFE,0x04,0x10,0x04,0x10,

0x3F,0xF0,0x04,0x10,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

};

/************************************************************/

/*************************右覆蓋數(shù)組************************/

/************************************************************/

uchar code table2[]={

0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,

0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00

};

/************************************************************/

/*************************左覆蓋數(shù)組************************/

/************************************************************/

uchar code table3[]={

0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,

0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00

};

/*****************************************/

/*****************延時(shí)子程序*************/

/***************************************/

void delay(uchar z)

{

uchar x,y;

for(x=2;x>0;x--)

for(y=z;y>0;y--);

}

/*****************************************/

/**************74HC595送數(shù)子程序********/

/***************************************/

void song(uchar z)//帶參數(shù)函數(shù)

{

uchar num,hang;//定義變量

hang=z;//將形參給變量

for(num=0;num<8;num++)//移動(dòng)8次將數(shù)據(jù)發(fā)送完畢

{

if(hang&0x01==1)//將高7位屏蔽掉,保留最低位判斷

DATA=1;//為1就將74HC595數(shù)據(jù)端置1

else

DATA=0;//否則給0

CLK=0;//上升沿送走數(shù)據(jù)

CLK=1;//高電平形成上升沿

hang>>=1;//將數(shù)移走一位

}

}

/************************************************************/

/************************************************************/

/**************************間斷顯示***************************/

/************************************************************/

/************************************************************/

void jian()

{

while(word<128)//要顯示多少字?

{

for(move=150;move>0;move--)//字間斷顯示的速度

{

ji=word;

for(line=0;line<16;line++)

{

song(~table[ji*2+1]);//先右半屏

song(~table[ji*2]);//再左半屏

ji++;//下一行

CLKR=1;//在74HC595處鎖存起來

CLKR=0;

CLKR=1;

LINE=line;//打開列

delay(17);

}

}

word=ji;

}

}

/************************************************************/

/************************************************************/

/**************************上移顯示***************************/

/************************************************************/

/************************************************************/

void shang()

{

while(word<128)

{

for(move=20;move>0;move--)

{

ji=word;//將變量存起來

for(line=0;line<16;line++)

{

song(~table[ji*2+1]);

song(~table[ji*2]);

ji++;

CLKR=1;//在74HC595處鎖存起來

CLKR=0;

CLKR=1;

LINE=line;

delay(5);

}

}

word+=1;//數(shù)組數(shù)增加一行,形成上移

}

}

/************************************************************/

/************************************************************/

/**************************下移顯示***************************/

/************************************************************/

/************************************************************/

void xia()

{

while(word>1)

{

for(move=20;move>0;move--)

{

ji=word;//給倒數(shù)第2個(gè)字位置地址碼給ji變量

for(line=0;line<16;line++)

{

song(~table1[ji*2+1]);//發(fā)右半屏數(shù) 注意這是數(shù)組1的代碼

song(~table1[ji*2]);//發(fā)左半屏數(shù)

ji++;

CLKR=1;//在74HC595處鎖存起來

CLKR=0;

CLKR=1;

LINE=line;

delay(5);

}

}

word-=1;//數(shù)組數(shù)減1一行,形成下移

}

}


上一頁 1 2 3 下一頁

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉