當(dāng)前位置:首頁 > 單片機 > 單片機
[導(dǎo)讀] //-----------------------------------------------------//// MCU:89C51晶振:12M#include #define uchar unsigned char#define uint unsigned intuint a=0,a1=0,a2=0;uint miusfla,miust,mius=64536

//-----------------------------------------------------
//<<12*12點陣+音樂產(chǎn)生>>
// MCU:89C51晶振:12M
#include
#define uchar unsigned char
#define uint unsigned int
uint a=0,a1=0,a2=0;
uint miusfla,miust,mius=64536;
uint disfla1,sta=0;
char flag=0,mdflag=0;
sbit k1=P3^2;
sbit k2=P3^3;
sbit YY=P3^1;

uchar code tabfas[]={
//==============笑臉===================================
//P0口
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
//P1口
0x8E,0x4D,0xAB,0x57,0x5F,0x9F,0x9F,0x5F,0x5F,0xAF,0x4F,0x8F,
0x8E,0x4D,0xAB,0x97,0x9F,0x9F,0x9F,0x9F,0x9F,0xAF,0x4F,0x8F,
//P2口
0x87,0x88,0x50,0x20,0xA4,0x68,0x68,0xA4,0x20,0x50,0x88,0x87,
0x87,0x88,0x50,0x20,0xA4,0x68,0x68,0xA4,0x20,0x50,0x88,0x87,
//P0口
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFE,0xFD,0xFB,0xF7,0xEF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,0x67,0xCF,0x4F,0x0F,0x8F,0x4F,0x4F,0x2F,0x0F, //新
//0x0E,0x0D,0x8B,0x47,0x7F,0x4F,0xCF,0x4F,0x4F,0x4F,0x4F,0x0F, //年
0x0E,0x0D,0xEB,0x07,0x8F,0x8F,0xEF,0x8F,0x8F,0x8F,0x0F,0x0F, //快
0x0E,0x8D,0x4B,0x47,0x4F,0xAF,0x1F,0x0F,0x0F,0x0F,0x0F,0x0F, //樂
0xCE,0x2D,0x2B,0x27,0x4F,0x8F,0x8F,0x4F,0x2F,0x2F,0x2F,0xCF, //心形
0x0F,0x0F,0x2B,0x27,0xAF,0x6F,0xFF,0x6F,0xAF,0x2F,0x2F,0x0F, //李
0x0E,0x0D,0x2B,0xA7,0xAF,0xFF,0xAF,0xAF,0x2F,0x0F,0x0F,0x0F, //春
0x0E,0x0D,0x4B,0x47,0xEF,0x4F,0x4F,0x8F,0x8F,0x8F,0x0F,0x0F, //起
//0x0E,0xFD,0x5B,0x57,0x5F,0xFF,0x0F,0x4F,0x4F,0xCF,0x4F,0x0F, //題
0xCE,0x2D,0x2B,0x27,0x4F,0x8F,0x8F,0x4F,0x2F,0x2F,0x2F,0xCF, //心形
//P2口
0x08,0x04,0xFE,0x05,0x08,0x43,0x3E,0x02,0x3E,0x23,0x30,0x00, //祝
0x00,0x09,0x0A,0x7F,0x2A,0x08,0x0F,0x09,0x7F,0x09,0x0F,0x00, //鐘
0x00,0x02,0x01,0x7F,0x02,0x22,0x22,0x3F,0x22,0x22,0x02,0x00, //仕
0xc0,0x3f,0x88,0x6a,0x2a,0xff,0x2a,0xff,0x2a,0x6a,0xde,0x88,//廉
0x00,0x21,0x20,0x20,0x24,0x24,0x3F,0x24,0x24,0x20,0x20,0x00, //生
0x00,0x00,0x00,0x3F,0x22,0x22,0x22,0x22,0x3F,0x00,0x00,0x00, //日
//0x00,0x2A,0x5A,0xFF,0x1A,0x2A,0x40,0x3F,0x02,0x7E,0x02,0x00, //新
//0x08,0x09,0x0F,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x08,0x00, //看
0x01,0x06,0x7F,0x22,0x14,0x0C,0x07,0x0C,0x14,0x27,0x24,0x00, //快
0x00,0x23,0x12,0x0E,0x22,0x7F,0x06,0x0A,0x13,0x22,0x00,0x00, //樂
0x03,0x04,0x08,0x10,0x20,0x60,0x20,0x10,0x08,0x04,0x02,0x01, //心形
0x00,0x00,0x11,0x11,0x12,0x52,0xFB,0x1A,0x16,0x11,0x11,0x00, //李
0x00,0x12,0x0A,0xFE,0xAB,0xAA,0xAA,0xFE,0x0A,0x12,0x00,0x00, //春
0x40,0x21,0x1D,0x09,0x1F,0x25,0x41,0x5D,0x54,0x53,0x58,0x00, //起
//0x84,0x45,0x35,0x3D,0x55,0x95,0x84,0xAF,0x9D,0x91,0xAF,0x80, //題
0x03,0x04,0x08,0x10,0x20,0x60,0x20,0x10,0x08,0x04,0x02,0x01, //心形
};
//----------------音符----------------------
uint code miusdata[]={
//祝你生日快樂
64260,64260,64399,64260,64579,64524,64260,64260,
64399,64260,64684,64580,64260,64260,64898,64777,
64580,64524,64399,64819,64819,64777,64580,64777,
64684,0,
64260,64260,64399,64260,64579,64524,64260,64260,
64399,64260,64684,64580,64260,64260,64898,64777,
64580,64524,64399,64819,64819,64777,64580,64684,
64580,0,
64580,64580,64684,64580,64819,64777,64580,64580,
64684,64580,64898,64819,64580,64580,65058,64968,
64819,64777,64684,65000,65000,64960,64819,64967,
64898,0,
64580,64580,64684,64580,64819,64777,64580,64580,
64684,64580,64898,64819,64580,64580,65058,64968,
64819,64777,64684,65000,65000,64960,64819,64898,
64819,0
};
//---------------節(jié)拍-----------------------
uchar code miustime[]={
40,40,80,80,80,160,40,40,80,80,80,160,40,40,
80,80,80,80,80,40,40,80,80,80,160,80,
40,40,80,80,80,160,40,40,80,80,80,160,40,40,
80,80,80,80,80,40,40,80,80,80,160,80,
40,40,80,80,80,160,40,40,80,80,80,160,40,40,
70,75,80,80,80,40,40,80,80,80,160,80,
40,40,80,80,80,160,40,40,80,80,80,160,40,40,
70,75,80,80,80,40,40,80,80,80,160,80,
};
void delay500();

//==========按鍵==========================================
void kk()
{
if(!k1){delay500();if(++flag>1)flag=0;else {a=72;a2=0;}sta=1;}
if(!k2){delay500();if(++mdflag>1)mdflag=0;sta=1;}
}
//=========延時===========================================
void delay(uint m)
{
uint i,j;
for(i=0;i {
for(j=0;j<300;j++)
{kk();if(sta){sta=0;goto abc;}}
}
abc:;
}
//------按鍵消拉動用----------------
void delay500()
{
uint i1;
P0=0XFF;
P1=0X0F;
P2=0X00;
for(i1=0;i1<32000;i1++);
}
//=========定時器T0用于頻率產(chǎn)生和顯示======================
void time0() interrupt 1
{
P0=0XFF;
P1=0X0F;
P2=0X00;
TH0=mius>>8;
TL0=mius&0xff;
YY=~YY;
switch(flag)
{
case 0:{ //笑臉
P0=tabfas[a];
P1=tabfas[a+24];
P2=tabfas[a+48];
if(++disfla1<700){if(++a>11)a=0;}
if(disfla1>=700){if(++a>23)a=11;}
if(disfla1>800){a=0;disfla1=0;}
}break;
case 1:{ //漢字
P0=tabfas[a];
P1=tabfas[a+192];
P2=tabfas[a+348];
if(++disfla1<500){if(++a>(a2+83))a=(a2+72);}
else{if(++a>(a2+83))a=(a2+72);}
if(disfla1>1000){a2+=12;disfla1=0;}
if(a2>144){a2=0;}
}break;
default:break;
}
}
//========定時器T1只用于顯示================================
void time1() interrupt 3
{
P0=0XFF;
P1=0X0F;
P2=0X00;
TH1=0xf8;
TL1=0x30;
switch(flag)
{
case 0:{ //笑臉
P0=tabfas[a];
P1=tabfas[a+24];
P2=tabfas[a+48];
if(++disfla1<700){if(++a>11)a=0;}
if(disfla1>=700){if(++a>23)a=11;}
if(disfla1>800){a=0;disfla1=0;}
}break;
case 1:{ //漢字
P0=tabfas[a];
P1=tabfas[a+192];
P2=tabfas[a+348];
if(++disfla1<500){if(++a>(a2+83))a=(a2+72);}
else{if(++a>(a2+83))a=(a2+72);}
if(disfla1>1000){a2+=12;disfla1=0;}
if(a2>144){a2=0;}
}break;
default:break;
}
}
/////////////////////////////////////////////////////////////
//=========================================================//
//----------------主程序-----------------------------------//
//=========================================================//
/////////////////////////////////////////////////////////////
void main()
{
P0=0XFF;
P1=0X0F;
P2=0X00;
P3=0XFD;
TMOD=0X11;
TH0=mius>>8;
TL0=mius&0xff;
TH1=0xf8;
TL1=0x30;
TR0=1;
ET0=1;
TR1=0;
ET1=1;
EA=1;
while(1)
{
switch(mdflag)
{
case 0:{//音樂暫停
TR0=0;TR1=1;kk();sta=0;
}break;
case 1:{ //音樂繼續(xù)
TR0=0;
delay(1);
TR0=1;
mius=miusdata[a1];
if(mius==0){TR0=0;TR1=1;}
else {TR1=0;TR0=1;}
delay(miustime[a1]);
if(++a1>=104)a1=0;
}break;
default:break;
}
}
}


本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫毥谦F公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風(fēng)險,如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅持高質(zhì)量發(fā)展策略,塑強核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學(xué)會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團(tuán))股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉