LED流水燈線路圖_第1頁
LED流水燈線路圖_第2頁
LED流水燈線路圖_第3頁
LED流水燈線路圖_第4頁
LED流水燈線路圖_第5頁
已閱讀5頁,還剩66頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

ORG0000HSETBP1.0DELAY:MOVR5,#60//延時(shí)子程序,延時(shí)600msD1:MOVR6,#20D2:MOVR7,#248DJNZR7,$DJNZR6,D2DJNZR5,D1RETENDORG0000HLJMPMAINORG0100HMOVR7,#200D1:MOVR6,#200D2:DJNZR6,D2DJNZR7,D1RETMOVR7,#250D4:MOVR6,#250D5:DJNZR6,D2DJNZR7,D4RETD3:MOVP2,ARLAMOVP2,ADJNZR5,D3MOVP2,#0RETMAIN:MOVR5,#7MOVA,#11111110BLCAllD3LJMPMAINEND程序3-1:ORG0000HLED數(shù)字顯示倒計(jì)時(shí)電路圖MOVDPTR,#CHARTLJMPMAINORG0100H0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90HMOVR7,#10DEL1:MOVR6,#200DEL2:MOVR5,#248DJNZR5,$DJNZR6,DEL2DJNZR7,DEL1RETLOOP:MOVA,R2MOVCA,@A+DPTRMOVP2,ADECR2DJNZR1,LOOPRETMAIN:MOVR1,#10MOVR2,#9LCALLLOOPLJMPMAINEND圖4-1LED加減按鍵電路圖程序4-1:ORG0000H;ORG0030HDISP:MOVA,R2MOVR2,#1LOOP:MOVDPTR,#TABMOVCA,@A+DPTRJBP1.6,NEXTCALLDL10MSRETJBP1.6,NEXTDL10MS:JNBP1.6,$MOVR6,#20DJNZR2,NEXTDJNZR7,$MOVR2,#10NEXT:RETJBP1.7,LOOP;CALLDL10MSJBP1.7,LOOPDB0C0H,0F9H,0A4H,0B0H,99HJNBP1.7,$DB92H,82H,0F8H,80H,90HINCR2;CJNER2,#11,LOOPEND程序5-1:ORG0000HNOLED:MOVP2,#0JBP1.0,LEDCALLNOLEDLED:MOVP2,#1END圖6-1電壓超限預(yù)警報(bào)警顯示電路圖程序6-1:#include<reg52.h>#defineucharunsignedchar#defineuintunsignedint//===========================//ADC0809相關(guān)引腳定義//===========================#defineADC_sbitADC_EOC=P3^3;sbitADC_CLK=P3^4;sbitADC_OE=P3^7;//===========================//4位共陽數(shù)碼管相關(guān)//===========================ucharcodeseg[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//0~9小數(shù)點(diǎn)不亮ucharcodeseg_dot[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//0~9小數(shù)點(diǎn)亮#defineSEG_DATAP2//數(shù)碼管段選碼,共陽數(shù)碼管,低電平選通段sbitSEG_SEL_0=P0^3;//數(shù)碼管位選:第0位,共陽數(shù)碼管,高電平選通位選碼SEG_SEL_1=P0^2;//數(shù)碼管位選:第1位SEG_SEL_2=P0^1;//數(shù)碼管位選:第2位SEG_SEL_3=P0^0;//數(shù)碼管位選:第3位//===========================//警報(bào):LED與蜂鳴器引腳//===========================sbitLED_Y=P0^5;//低電平亮sbitBEEP=P0^4;//高電平響sbitLED_R=P0^6;sbitLED_G=P0^7;#defineBEEP_ONBEEP=1#defineBEEP_OFFBEEP=0#defineLED_Y_ONLED_Y=0#defineLED_Y_OFFLED_Y=1#defineLED_R_ONLED_R=0#defineLED_R_OFFLED_R=1#defineLED_G_ONLED_G=0#defineLED_G_OFFLED_G=1//===========================//粗略延時(shí)函數(shù)AT89C51&12MHz//===========================voiddelayms(unsignedintms){unsignedchara,b,c;while(ms--){for(c=1;c>0;c--)for(b=142;b>0;b--)for(a=2;a>0;a--);}}/*//===========================//粗略延時(shí)函數(shù)STC12C5A60S2&12MHz//===========================voiddelayms(unsignedintms){unsignedchara,b,c;while(ms--){for(c=1;c>0;c--)for(b=222;b>0;b--)for(a=12;a>0;a--);}}//===========================//定時(shí)器初始化,配置ADC0809時(shí)鐘//===========================voidtimer_init(void){//配置定時(shí)器0TMOD&=0xF0;TH0=200;TL0=200;//配置定時(shí)器1TMOD&=0x0F;//定時(shí)器0,模式2,自動(dòng)重裝定時(shí)器//自動(dòng)重裝值//清除定時(shí)器1配置,不改動(dòng)定時(shí)器0的配置//定時(shí)器1模式一,不改動(dòng)定時(shí)器0的模式TH1=(65536-2000)/256;TL1=(65536-2000)%256;}//===========================//定時(shí)器0中斷,為ADC0809提供時(shí)鐘信號(hào)//===========================voidtimer0()interrupt1{ADC_CLK=~ADC_CLK;}//============================//ADC0809轉(zhuǎn)換函數(shù)//============================ucharADC0809_GET(void){ADC_OE=0;while(ADC_EOC==0);ADC_OE=1;}//============================//定時(shí)器1中斷函數(shù),用于刷新數(shù)碼管//============================uchart1_flag=0;//用于標(biāo)記顯示第幾位數(shù)碼管ucharseg0=0;//第0位數(shù)碼管的值//第1位數(shù)碼管的值ucharseg2=2;//第2位數(shù)碼管的值ucharseg3=3;//第3位數(shù)碼管的值voidtimer1()interrupt3{TH1=(65536-2000)/256;TL1=(65536-2000)%256;SEG_SEL_0=0;SEG_SEL_2=0;SEG_SEL_3=0;if(t1_flag==0){SEG_SEL_0=1;//選通第0位數(shù)碼管SEG_SEL_2=0;SEG_SEL_3=0;SEG_DATA=seg_dot[seg0];//顯示帶小數(shù)點(diǎn)的數(shù)}elseif(t1_flag==1){SEG_SEL_0=0;SEG_SEL_2=0;SEG_SEL_3=0;}elseif(t1_flag==2){SEG_SEL_0=0;SEG_SEL_2=1;//選通第2位數(shù)碼管SEG_SEL_3=0;}elseif(t1_flag==3){SEG_SEL_0=0;SEG_SEL_2=0;SEG_SEL_3=1;//選通第3位數(shù)碼管}t1_flag++;//自加1t1_flag=t1_flag%4;//讓t1_flag在0和3之間循環(huán)}//============================//顯示電壓值,輸入0~255,顯示0.000~5.000//============================uintprint_volt(ucharnum){uintvolt=0;volt=num/255.0*5000+0.5;//除255.0和除255有很大區(qū)別,除255.0會(huì)自動(dòng)轉(zhuǎn)換為float型,小數(shù)才能保持,而volt/255=0,+0.5四舍五入。seg0=volt/1000%10;seg1=volt/100%10;seg2=volt/10%10;seg3=volt%10;returnvolt;}//============================//主函數(shù)//============================voidmain(void){ucharadc_num=0;uintvolt=0;timer_init();LED_Y_OFF;LED_R_OFF;LED_G_ON;//ADC采集到的值//電壓值0~5000,代表(0~5)VBEEP_OFF;while(1){adc_num=ADC0809_GET();if(volt>2500){LED_G_OFF;LED_Y_OFF;LED_R_ON;BEEP_ON;}elseif(volt>2400){LED_Y_ON;LED_G_OFF;LED_R_OFF;BEEP_OFF;}{LED_G_ON;LED_Y_OFF;LED_R_OFF;BEEP_OFF;}delayms(100);}}圖7-1128*64LCD讀取系統(tǒng)時(shí)間并顯示程序7-1:#include<reg52.h>#include<ABSACC.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedint/********各種指令的宏定義********/#defineLLCD_CMD_WRPBYTE[0x10]//#defineLLCD_CMD_RDPBYTE[0x11]//#defineLLCD_DATA_WRPBYTE[0x12]//#defineLLCD_DATA_RDPBYTE[0x13]//#defineRLCD_CMD_WRPBYTE[0x20]//#defineRLCD_CMD_RDPBYTE[0x21]//LCD左半部寫的命令rs=0,wr=0LCD右半部部分#defineRLCD_DATA_WRPBYTE[0x22]//#defineRLCD_DATA_RDPBYTE[0x23]//#defineWRITE_SECOND0x80#defineWRITE_MINUTE0x82#defineWRITE_HOUR0x84#defineWRITE_DAY0x86#defineWRITE_MOUTH0x88#defineWRITE_YEAR0x8c#defineREAD_SECOND0x81#defineREAD_MINUTE0x83#defineREAD_HOUR0x85#defineREAD_DAY0x87#defineREAD_MOUTH0x89#defineREAD_YEAR0x8d#defineWRITE_PROTECT0x8E/*************************/sbitSCK=P1^1;sbitDIO=P1^0;sbitCE=P1^2;sbitK1=P1^5;sbitK2=P1^6;sbitK3=P1^7;sbitbusy=P0^7;ucharsec,min,hour,day,mouth,year,print;ucharbuffer[16];codeucharshuzi1[]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//00x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//10x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//20x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//30x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//40x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//50x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//60x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//70x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//80x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//90x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//空codeucharshijian1[]={0x00,0xFC,0x44,0x44,0x44,0xFC,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,0x00,0x07,0x04,0x04,0x04,0x07,0x00,0x00,0x03,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0x06,0x00,0xF0,0x92,0x92,0x92,0x92,0xF2,0x02,0x02,0xFE,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x07,0x40,0x80,0x7F,0x00,0x00,codeucharriqi1[]={0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00,0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00,voidlcd_busy_rd(ucharright){if(right==1)RLCD_CMD_RD;LLCD_CMD_RD;while(busy);}/**********寫指令***********/voidlcd_comd_wr(ucharcmdcode,ucharright)//寫指令{lcd_busy_rd(right);if(right==1)RLCD_CMD_WR=cmdcode;LLCD_CMD_WR=cmdcode;}/********對(duì)LCD進(jìn)行讀寫***********/voidlcd_data_wr(ucharldata,ucharright)//{lcd_busy_rd(right);if(right==1)}/********延時(shí)函數(shù)*******/voiddelay(uintnms){uinti;while(nms--)for(i=0;i<500;i++);}/****lcd初始化*******/voidlcd_init(void){uintk;lcd_comd_wr(0x3e+1,0);//左半部顯示開lcd_comd_wr(0xc0+0,0);//左半部頂行為第0行l(wèi)cd_comd_wr(0xb0+0,0);//設(shè)置左半部頁的地址lcd_comd_wr(0x40+0,0);//設(shè)置左列得地址lcd_comd_wr(0x3e+1,1);lcd_comd_wr(0xc0+0,1);lcd_comd_wr(0x40+0,1);lcd_comd_wr(0xb0+0,1);for(k=0;k<256;k++){lcd_data_wr(0x00,0);lcd_data_wr(0x00,1);}lcd_comd_wr(0xb8+4,0);lcd_comd_wr(0x40+0,0);lcd_comd_wr(0xb8+4,1);lcd_comd_wr(0x40+0,1);for(k=0;k<256;k++){lcd_data_wr(0x00,0);lcd_data_wr(0x00,1);}//這個(gè)for循環(huán)是為清楚不顯示字的地方}/**********顯示漢字****************//*********置入單個(gè)數(shù)字*********/voidlcd_shuzi_wr(ucharposx,ucharposy,uchar*shuzi){uchari1;if(posy<8){lcd_comd_wr(0xb8+2*posx,0);//左半部頁的地址,相當(dāng)于行掃描上半部分lcd_comd_wr(0x40+8*posy,0);//左半部列的地址for(i1=0;i1<8;i1++){lcd_data_wr(shuzi[i1],0);}lcd_comd_wr(0xb8+2*posx+1,0);//同上下部分的漢字lcd_comd_wr(0x40+8*posy,0);for(i1=8;i1<16;i1++){lcd_data_wr(shuzi[i1],0);}}else//否則右半部寫{lcd_comd_wr(0xb8+2*posx,1);lcd_comd_wr(0x40+8*(posy-8),1);for(i1=0;i1<8;i1++){lcd_data_wr(shuzi[i1],1);}lcd_comd_wr(0xb8+2*posx+1,1);lcd_comd_wr(0x40+8*(posy-8),1);for(i1=8;i1<16;i1++){lcd_data_wr(shuzi[i1],1);}}}/**********輸出方式**************//****n=空幾格的數(shù)************/voidlcd_num_wr(ucharrow,ucharcol,ucharn,uchar*str){uchari2;for(i2=print;i2<n;i2++){if(col>15){row++;col=col-16;}lcd_shuzi_wr(row,col,str+buffer[i2]*16);//i2=寫入的數(shù)字col++;}}/**********顯示漢字****************//*********置入單個(gè)漢字**********/voidlcd_hanzi_wr(ucharposx,ucharposy,uchar*hanzi){uchari1;if(posy<4){lcd_comd_wr(0xb8+2*posx,0);//左半部頁的地址,相當(dāng)于行掃描上半部分lcd_comd_wr(0x40+16*posy,0);//左半部列的地址for(i1=0;i1<16;i1++){lcd_data_wr(hanzi[i1],0);}lcd_comd_wr(0xb8+2*posx+1,0);//同上下部分的漢字lcd_comd_wr(0x40+16*posy,0);for(i1=16;i1<32;i1++){lcd_data_wr(hanzi[i1],0);}}else//否則右半部寫{lcd_comd_wr(0xb8+2*posx,1);lcd_comd_wr(0x40+16*(posy-4),1);for(i1=0;i1<16;i1++){lcd_data_wr(hanzi[i1],1);}lcd_comd_wr(0xb8+2*posx+1,1);lcd_comd_wr(0x40+16*(posy-4),1);for(i1=16;i1<32;i1++){lcd_data_wr(hanzi[i1],1);}}}/**********輸出方式**************//****n=空幾格的數(shù)************/voidlcd_str_wr(ucharrow,ucharcol,ucharn,uchar*str){uchari2;for(i2=0;i2<n;i2++){if(col>7){row++;col=col-8;}lcd_hanzi_wr(row,col,str+i2*32);col++;}}/***讀出一個(gè)字節(jié)**********/ucharRead1302_byte(ucharaddr){uchari3,dat1,dat2;CE=0;_nop_();_nop_();CE=1;_nop_();for(i3=0;i3<8;i3++)//寫入要讀的字節(jié)的地址{DIO=addr&0x01;addr=addr>>1;}for(i3=0;i3<8;i3++)//讀數(shù)據(jù){dat1=dat1>>1;if(DIO)}CE=0;_nop_();_nop_();DIO=1;dat2=dat1/16;//將16進(jìn)制轉(zhuǎn)化為10進(jìn)制dat1=dat1%16;dat1=dat2*10+dat1;return(dat1);}/***x寫入一個(gè)字節(jié)**********/voidwrite_ds1302(ucharaddr,uchardat){uchari2;CE=0;_nop_();SCK=0;_nop_();CE=1;_nop_();for(i2=0;i2<8;i2++)//寫入要寫的字節(jié)的地址{DIO=addr&0x01;addr=addr>>1;}for(i2=0;i2<8;i2++)//寫數(shù)據(jù){DIO=dat&0x01;dat=dat>>1;}CE=0;_nop_();DIO=1;}/*****將ds1302的數(shù)據(jù)分離**********/voidzh(){buffer[0]=year/10;buffer[1]=year%10;buffer[2]=11;buffer[3]=mouth/10;buffer[4]=mouth%10;buffer[5]=11;buffer[6]=day/10;buffer[7]=day%10;buffer[8]=hour/10;buffer[9]=hour%10;buffer[10]=10;buffer[11]=min/10;buffer[12]=min%10;buffer[13]=10;buffer[14]=sec/10;buffer[15]=sec%10;}/**********讀都ds1302的數(shù)據(jù)**********/voidread(){sec=Read1302_byte(READ_SECOND);min=Read1302_byte(READ_MINUTE);hour=Read1302_byte(READ_HOUR);day=Read1302_byte(READ_DAY);mouth=Read1302_byte(READ_MOUTH);year=Read1302_byte(READ_YEAR);}/***********鍵盤掃描***********/voidkey(){ucharw;if(K1==0){while(!K1);write_ds1302(WRITE_PROTECT,0x00);min++;if(min>=60){min=0;hour++;if(hour>=24){hour=0;write_ds1302(WRITE_HOUR,hour);}}w=min/10;min=min%10;min=min+w*16;//進(jìn)制轉(zhuǎn)換10進(jìn)制轉(zhuǎn)換16進(jìn)制write_ds1302(WRITE_MINUTE,min);//把調(diào)整后的時(shí)鐘寫入到時(shí)鐘芯片中}if(K2==0){while(!K2);write_ds1302(WRITE_PROTECT,0x00);hour++;if(hour>=24){hour=0;}w=hour/10;hour=hour%10;hour=hour+w*16;write_ds1302(WRITE_HOUR,hour);}write_ds1302(WRITE_PROTECT,0x80);print=0;lcd_num_wr(1,5,8,shuzi1);//寫入到第幾行,第幾個(gè)開始,和寫入的字?jǐn)?shù),寫入的指針print=8;lcd_num_wr(2,5,16,shuzi1);}/*******主程序*************/voidmain(){lcd_init();delay(100);while(1){key();read();zh();print=0;lcd_num_wr(1,5,8,shuzi1);//寫入到第幾行,第幾個(gè)開始,和寫入的字?jǐn)?shù),寫入的指針print=8;lcd_num_wr(2,5,16,shuzi1);lcd_str_wr(2,0,2,shijian1);lcd_str_wr(1,0,2,riqi1);}}圖8-1128*64LCD滾動(dòng)顯示系統(tǒng)時(shí)間、姓名、班級(jí)等電路圖#include<reg51.h>#defineucharunsignedchar#defineuintunsignedint#defineLCDLCDDisp_Off0x3e#defineLCDLCDDisp_On0x3f#definePage_Add0xb8//ye#defineLCDCol_Add0x40//lie#defineStart_Line0xC0//hang/*****液晶顯示器的端口定義*****/#definedata_oraP0/*液晶數(shù)據(jù)總線*/sbitLCDMcs=P2^4;sbitLCDScs=P2^3;sbitLCDDi=P2^2;sbitLCDRW=P2^1;sbitLCDEnable=P2^0;ucharcodehz1[]={/*片選2*//*數(shù)據(jù)/指令選擇*//*讀/寫選擇*//*讀/寫使能*/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,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:50*/0x02,0x02,0xE2,0x22,0x22,0xFE,0x22,0x22,0x22,0xFE,0x22,0x22,0xE2,0x02,0x02,0x00,0x00,0x00,0xFF,0x48,0x44,0x43,0x40,0x40,0x40,0x43,0x44,0x44,0xFF,0x00,0x00,0x00,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:51*/0x80,0x90,0x8C,0x84,0x84,0x84,0xF5,0x86,0x84,0x84,0x84,0x84,0x94,0x8C,0x80,0x00,0x00,0x80,0x80,0x84,0x46,0x49,0x28,0x10,0x10,0x2C,0x23,0x40,0x80,0x00,0x00,0x00,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:52*/0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x08,0x06,0x01,0xFF,0x00,0x01,0x04,0x04,0x04,0x04,0x04,0xFF,0x02,0x02,0x02,0x00,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:53*/0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:53*/0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,/*字模格式/大小:單色點(diǎn)陣液晶字模,縱向取模,字節(jié)倒序/32字節(jié)數(shù)據(jù)轉(zhuǎn)換日期:2010-7-3115:54*/0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,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,0x00ucharcodehz2[]={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,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x83,0x60,0x1F,0x00,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x10,0x10,0xD0,0xFF,0x90,0x00,0x10,0xD0,0x10,0xD0,0x10,0xFF,0x10,0x92,0x14,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x31,0x0F,0x01,0xBF,0x41,0x27,0x38,0x47,0xF0,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,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,ucharcodehz3[]={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,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x83,0x60,0x1F,0x00,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x10,0x10,0xD0,0xFF,0x90,0x00,0x10,0xD0,0x10,0xD0,0x10,0xFF,0x10,0x92,0x14,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x31,0x0F,0x01,0xBF,0x41,0x27,0x38,0x47,0xF0,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00,0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x80,0x82,0x82,0x82,0x82,0x82,0x82,0xE2,0xA2,0x92,0x8A,0x86,0x82,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,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,0x00ucharcodehz4[]={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,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,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x40,0x44,0x54,0x54,0x55,0x56,0xD4,0x7C,0x54,0x56,0x55,0x54,0x54,0x44,0x40,0x00,0x02,0x82,0x82,0x9A,0x56,0x53,0x22,0x22,0x22,0x52,0x4E,0x42,0x82,0x02,0x02,0x00,/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x20,0x40,0x80,0x00,0x00,0x08,0x04,0x03,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x01,0x0E,0x00,、/*--宋體12;此字體下對(duì)應(yīng)的點(diǎn)陣為:寬x高=16x16--*/0x40,0x21,0x11,0x09,0x7D,0x4B,0x49,0x49,0x49,0x49,0x49,0x79,0x01,0x01,0x00,0x00,0x10,0x09,0xFD,0x4B,0x49,0x49,0xF9,0x10,0x09,0xFD,0x4B,0x49,0x49,0xF9,0x01,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,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,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ù):t****************************************************************************/voidLCDdelay(ucharx){uchary;for(y=0;y<x;y++)for(d=0;d<10;d++);}/*********************************************************************************************************************************************************/voidCheckState(){uchardat,DATA;//狀態(tài)信息(判斷是否忙)LCDRW=1;//R/W="H",E="H"數(shù)據(jù)被讀到DB7∽DB0{LCDEnable=1;//EN下降源LCDdelay(1);//延時(shí)LCDEnable=0;dat=0x80&dat;//僅當(dāng)?shù)?位為0時(shí)才可操作(判別busy信號(hào))}while(!(dat==0x00));}/*****************************************************************************入口參數(shù):cmdcode*****************************************************************************/voidwrite_com(ucharcmdcode){CheckState();//檢測(cè)LCD是否忙LCDDi=0;LCDRW=0;P1=cmdcode;LCDdelay(1);LCDEnable=1;LCDdelay(1);LCDEnable=0;}/*****************************************************************************入口參數(shù):LCDDispdata*****************************************************************************/voidwrite_data(ucharLCDDispdata){CheckState();//檢測(cè)LCD是否忙LCDDi=1;LCDRW=0;P1=LCDDispdata;LCDdelay(1);LCDEnable=1;LCDdelay(1);LCDEnable=0;}/*****************************************************************************/*****************************************************************************函數(shù)功能:LCD初始化程序入口參數(shù):*****************************************************************************/voidinit_lcd(){LCDdelay(1);LCDMcs=1;//剛開始關(guān)閉兩屏LCDScs=1;LCDdelay(1);write_com(LCDLCDDisp_Off);//寫初始化命令write_com(Page_Add+0);write_com(Start_Line+0);write_com(LCDCol_Add+0);write_com(LCDLCDDisp_On);}/**************************************************************************入口參數(shù):pag,col,hzk*****************************************************************************/voidClr_Scr(){ucharj,k;LCDMcs=0;//左、右屏均開顯示LCDScs=0;write_com(Page_Add+0);write_com(LCDCol_Add+0);for(k=0;k<8;k++)//控制頁數(shù)0-7,共8頁{write_com(Page_Add+k);//每頁每頁進(jìn)行寫for(j=0;j<64;j++)//每頁最多可寫32個(gè)中文文字或64個(gè)ASCII字符{write_com(LCDCol_Add+j);write_data(0x00);//控制列數(shù)0-63,共64列,寫點(diǎn)內(nèi)容,列地址自動(dòng)加1}}}/*****************************************************************************函數(shù)功能:一行一行顯示入口參數(shù):page,column,hzk*****************************************************************************/Disp(ucharpage,ucharcolumn,ucharcode*word){uchari;//左屏LCDMcs=0;LCDScs=1;//上半字write_com(0xb8|page);write_com(0x40|column);for(i=0;i<16;i++)write_data(word[i]);for(i=32;i<48;i++)write_data(word[i]);for(i=64;i<80;i++)write_data(word[i]);for(i=96;i<112;i++)write_data(word[i]);//下半字write_com(0xb8|page+1);write_com(0x40|column);for(i=16;i<32;i++)write_data(word[i]);for(i=48;i<64;i++)write_data(word[i]);for(i=80;i<96;i++)write_data(word[i]);for(i=112;i<128;i++)write_data(word[i]);//右屏LCDMcs=1;LCDScs=0;//上半字write_com(0xb8|page);write_com(0x40);for(i=128;i<144;i++)write_data(word[i]);for(i=160;i<176;i++)write_data(word[i]);for(i=192;i<208;i++)write_data(word[i]);for(i=224;i<240;i++)write_data(word[i]);//下半字write_com(0xb8|page+1);write_com(0x40);for(i=144;i<160;i++)write_data(word[i]);for(i=176;i<192;i++)write_data(word[i]);for(i=208;i<224;i++)write_data(word[i]);for(i=240;i<250;i++)write_data(word[i]);}voidmain(){uintk=0;init_lcd();Clr_Scr();k=0;for(k=0xc0;k<0xff;k++){Disp(0,0,hz1);Disp(2,0,hz2);Disp(4,0,hz3);Disp(6,0,hz4);LCDMcs=0;LCDScs=0;write_com(k);LCDdelay(2);}while(1){}}圖9-1智能溫度控制系統(tǒng)電路圖程序9-1:#include"main.h"#include"delay.h"#include"ds1302.h"#include"KS0108.h"#include"IIC.h"#include"ds18B20.h"#include"serial.h"http://端口定義sbitSPEAK=P1^0;//報(bào)警器控制管腳sbitLED_NOR=P1^3;//正常指示燈控制管腳sbitLED_OVER=P1^4;//溫度上限指示燈控制管腳sbitLED_LOW=P1^5;//溫度下限指示燈控制管腳sbitMOTO=P1^2;//風(fēng)機(jī)控制管腳sbitHEAT=P1^1;//加熱設(shè)備控制管腳//sbitRXD=P3^0;//reg51.h中已經(jīng)定義//sbitTXD=P3^1;//reg51.h中已經(jīng)定義sbitK_MOTO=P3^2;//控制風(fēng)機(jī)按鍵sbitK_HEAT=P3^3;//控制加熱設(shè)備的按鍵#defineDAT_ADDR0x03//IICEEPROM中保存的溫度上、下限的地址/************************************************************************************************************/voidint0_inter()interrupt0{if(K_MOTO==0){MOTO=~MOTO;if(MOTO==0){g_pc_cont&=0x0C;}}}/************************************************************************************************************/voidint1_inter()interrupt2{{g_pc_cont&=0x03;}}/*******************************************************返回值:無******************************************************/voidtimer0_inter()interrupt1{//250us*4=1msstaticuchartimer=0;staticucharspeaker=0;if(speaker<235)//控制蜂鳴器聲音間隔{if(timer++==3)//控制報(bào)警器聲音{SPEAK=~SPEAK;timer=0;speaker++;}{if(timer++==4){speaker++;}}}/*******************************************************返回值:無******************************************************/voidport_init(void){LED_NOR=1;LED_OVER=0;LED_LOW=0;MOTO=0;}/*******************************************************返回值:無******************************************************/voidtimer0_init(void){TL0=0x06;//定時(shí)器初始值TH0=0x06;TMOD|=2;//定時(shí)器模式,工作方式2}/*******************************************************返回值:無******************************************************/voidint_init(void){IT0=1;//下降沿觸發(fā)EX0=1;//外部中斷打開}/*******************************************************返回值:無******************************************************/voidopen_moto(ucharopen){if(open==0){MOTO=0;g_pc_cont^=0x2;{g_pc_cont^=0x1;}}/*******************************************************返回值:無******************************************************/voidopen_heat(ucharopen){if(open==0){g_pc_cont^=0x8;{g_pc_cont^=0x4;}}/*******************************************************返回值:無******************************************************/voidset_temper_updown(uchardown,ucharup){write_IIC(DAT_ADDR,down);delay_ms(2);write_IIC(DAT_ADDR+1,up);}/*******************************************************參數(shù):pBuff保存系統(tǒng)時(shí)間:年、月、日、時(shí)、分、秒、星期*返回值:無******************************************************/voidset_system_time(uchar*pBuff){SYSTEM_TIMEstr_time;str_time.year=pBuff[0];str_time.month=pBuff[1];str_time.date=pBuff[2];str_time.hour=pBuff[3];str_time.min=pBuff[4];str_time.sec=pBuff[5];str_time.day=pBuff[6];set_time(str_time);}/*******************************************************參數(shù):pBuff保存溫度整數(shù)、小數(shù)值*返回值:無******************************************************/voidget_temper(uchar*pBuff){ucharpTmpBuff[2]={0,0};read_temper(pTmpBuff);//pBuff[0]整數(shù)、pBuff[1]小數(shù)部分*pBuff=pTmpBuff[0];*(pBuff+1)=pTmpBuff[1];}/*******************************************************返回值:無******************************************************/voidget_temper_updown(uchar*pDown,uchar*pUp){*pDown=read_IIC(DAT_ADDR);*pUp=read_IIC(DAT_ADDR+1);}/*******************************************************參數(shù):pBuff保存系統(tǒng)時(shí)間:年、月、日、時(shí)、分、秒、星期*返回值:無******************************************************/voidget_syste

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論