附件為:LCD12864顯示漢字和數(shù)字的程序與電路 /* 自定義延時(shí)子函數(shù) */ void delayms(uchar z) { int x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } /* 判斷LCD忙信號(hào)狀態(tài) */ void buys() { int dat; RW=1; RS=0; do { P0=0x00; E=1; dat=P0; E=0; dat=0x80 & dat; } while(!(dat==0x00)); } /* LCD寫指令函數(shù) */ void w_com(uchar com) { //buys(); RW=0; RS=0; E=1; P0=com; E=0; } /* LCD寫數(shù)據(jù)函數(shù) */ void w_date(uchar date) { //buys(); RW=0; RS=1; E=1; P0=date; E=0; } /* LCD選屏函數(shù) */ void select_screen(uchar screen) { switch(screen) { case 0: //選擇全屏 CS1=0; CS2=0; break; case 1: //選擇左屏 CS1=0; CS2=1; break; case 2: //選擇右屏 CS1=1; CS2=0; break; /* case 3: //選擇右屏 CS1=1; CS2=1; break; */ } } /* LCDx向上滾屏顯示 */ void lcd_rol() { int x; for(x=0;x<64;x++) { select_screen(0); w_com(0xc0+x); delayms(500); } } /* LCD清屏函數(shù):清屏從第一頁(yè)的第一列開始,總共8頁(yè),64列 */ void clear_screen(screen) { int x,y; select_screen(screen); //screen:0-選擇全屏,1-選擇左半屏,2-選擇右半屏 for(x=0xb8;x<0xc0;x++) //從0xb8-0xbf,共8頁(yè) { w_com(x); w_com(0x40); //列的初始地址是0x40 for(y=0;y<64;y++) { w_date(0x00); } } } /* LCD顯示漢字字庫(kù)函數(shù) */ void lcd_display_hanzi(uchar screen,uchar page,uchar col,uint mun) { //screen:選擇屏幕參數(shù),page:選擇頁(yè)參數(shù)0-3,col:選擇列參數(shù)0-3,mun:顯示第幾個(gè)漢字的參數(shù) int a; mun=mun*32; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*16)); for ( a=0;a<16;a++) { w_date(hanzi[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*16)); for ( a=0;a<16;a++) { w_date(hanzi[mun++]); } } /* LCD顯示字符字庫(kù)函數(shù) */ void lcd_display_zifuk(uchar screen,uchar page,uchar col,uchar mun) { //screen:選擇屏幕參數(shù),page:選擇頁(yè)參數(shù)0-3,col:選擇列參數(shù)0-7,mun:顯示第幾個(gè)漢字的參數(shù) int a; mun=mun*16; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(zifu[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(zifu[mun++]); } } /* LCD顯示數(shù)字字庫(kù)函數(shù) */ void lcd_display_shuzi(uchar screen,uchar page,uchar col,uchar mun) { //screen:選擇屏幕參數(shù),page:選擇頁(yè)參數(shù)0-3,col:選擇列參數(shù)0-7,mun:顯示第幾個(gè)漢字的參數(shù) int a; mun=mun*16; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(shuzi[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(shuzi[mun++]); } } /* LCD初始化函數(shù) */ void lcd_init() { w_com(0x3f); //LCD開顯示 w_com(0xc0); //LCD行初始地址,共64行 w_com(0xb8); //LCD頁(yè)初始地址,共8頁(yè) w_com(0x40); //LCD列初始地址,共64列 } /* LCD顯示主函數(shù) */ void main() { //第一行 int x; lcd_init(); //LCD初始化 clear_screen(0); //LCD清屏幕 lcd_display_shuzi(1,0,4,5); //LCD顯示數(shù)字 lcd_display_shuzi(1,0,5,1); //LCD顯示數(shù)字 lcd_display_hanzi(1,0,3,0); //LCD顯示漢字 lcd_display_hanzi(2,0,0,1); //LCD顯示漢字 //LCD字符漢字 lcd_display_hanzi(2,0,1,2); //LCD顯示漢字 //第二行 lcd_display_zifuk(1,1,2,0); //LCD顯示字符 lcd_display_zifuk(1,1,3,0); //LCD顯示字符 lcd_display_zifuk(1,1,4,0); //LCD顯示字符 lcd_display_zifuk(1,1,5,4); //LCD顯示字符 lcd_display_shuzi(1,1,6,8); //LCD顯示字符 lcd_display_shuzi(1,1,7,9); //LCD顯示字符 lcd_display_shuzi(2,1,0,5); //LCD顯示字符 lcd_display_shuzi(2,1,1,1); //LCD顯示字符 lcd_display_zifuk(2,1,2,4); lcd_display_zifuk(2,1,3,1); lcd_display_zifuk(2,1,4,2); lcd_display_zifuk(2,1,5,3); //第三行 for(x=0;x<4;x++) { lcd_display_hanzi(1,2,x,3+x); //LCD顯示漢字 } for(x=0;x<4;x++) { lcd_display_hanzi(2,2,x,7+x); //LCD顯示漢字 } //第四行 for(x=0;x<4;x++) { lcd_display_zifuk(1,3,x,5+x); //LCD顯示漢字 } lcd_display_shuzi(1,3,4,7); lcd_display_shuzi(1,3,5,5); lcd_display_shuzi(1,3,6,5); lcd_display_zifuk(1,3,7,9); lcd_display_shuzi(2,3,0,8); lcd_display_shuzi(2,3,1,9); lcd_display_shuzi(2,3,2,9); lcd_display_shuzi(2,3,3,5); lcd_display_shuzi(2,3,4,6); lcd_display_shuzi(2,3,5,8); lcd_display_shuzi(2,3,6,9); lcd_display_shuzi(2,3,7,2); while(1); /* while(1) { // LCD向上滾屏顯示 lcd_rol(); } */ }
標(biāo)簽: 12864 LCD 漢字 數(shù)字
上傳時(shí)間: 2013-11-08
上傳用戶:aeiouetla
TLC2543是TI公司的12位串行模數(shù)轉(zhuǎn)換器,使用開關(guān)電容逐次逼近技術(shù)完成A/D轉(zhuǎn)換過程。由于是串行輸入結(jié)構(gòu),能夠節(jié)省51系列單片機(jī)I/O資源;且價(jià)格適中,分辨率較高,因此在儀器儀表中有較為廣泛的應(yīng)用。 TLC2543的特點(diǎn) (1)12位分辯率A/D轉(zhuǎn)換器; (2)在工作溫度范圍內(nèi)10μs轉(zhuǎn)換時(shí)間; (3)11個(gè)模擬輸入通道; (4)3路內(nèi)置自測(cè)試方式; (5)采樣率為66kbps; (6)線性誤差±1LSBmax; (7)有轉(zhuǎn)換結(jié)束輸出EOC; (8)具有單、雙極性輸出; (9)可編程的MSB或LSB前導(dǎo); (10)可編程輸出數(shù)據(jù)長(zhǎng)度。 TLC2543的引腳排列及說明 TLC2543有兩種封裝形式:DB、DW或N封裝以及FN封裝,這兩種封裝的引腳排列如圖1,引腳說明見表1 TLC2543電路圖和程序欣賞 #include<reg52.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int sbit clock=P1^0; sbit d_in=P1^1; sbit d_out=P1^2; sbit _cs=P1^3; uchar a1,b1,c1,d1; float sum,sum1; double sum_final1; double sum_final; uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uchar wei[]={0xf7,0xfb,0xfd,0xfe}; void delay(unsigned char b) //50us { unsigned char a; for(;b>0;b--) for(a=22;a>0;a--); } void display(uchar a,uchar b,uchar c,uchar d) { P0=duan[a]|0x80; P2=wei[0]; delay(5); P2=0xff; P0=duan[b]; P2=wei[1]; delay(5); P2=0xff; P0=duan[c]; P2=wei[2]; delay(5); P2=0xff; P0=duan[d]; P2=wei[3]; delay(5); P2=0xff; } uint read(uchar port) { uchar i,al=0,ah=0; unsigned long ad; clock=0; _cs=0; port<<=4; for(i=0;i<4;i++) { d_in=port&0x80; clock=1; clock=0; port<<=1; } d_in=0; for(i=0;i<8;i++) { clock=1; clock=0; } _cs=1; delay(5); _cs=0; for(i=0;i<4;i++) { clock=1; ah<<=1; if(d_out)ah|=0x01; clock=0; } for(i=0;i<8;i++) { clock=1; al<<=1; if(d_out) al|=0x01; clock=0; } _cs=1; ad=(uint)ah; ad<<=8; ad|=al; return(ad); } void main() { uchar j; sum=0;sum1=0; sum_final=0; sum_final1=0; while(1) { for(j=0;j<128;j++) { sum1+=read(1); display(a1,b1,c1,d1); } sum=sum1/128; sum1=0; sum_final1=(sum/4095)*5; sum_final=sum_final1*1000; a1=(int)sum_final/1000; b1=(int)sum_final%1000/100; c1=(int)sum_final%1000%100/10; d1=(int)sum_final%10; display(a1,b1,c1,d1); } }
上傳時(shí)間: 2013-11-19
上傳用戶:shen1230
#include<reg51.h> //包含單片機(jī)寄存器的頭文件 /******************************************************* 函數(shù)功能:主函數(shù) (C 語(yǔ)言規(guī)定必須有也只能有1 個(gè)主函數(shù)) ********************************************************/ void main(void) { while(1) //無限循環(huán) { P1=0xff; // P1=1111 1111B,熄滅LED P0=P1; // 將 P1 口狀態(tài)送入P0 口 P2=P1; // 將 P1 口狀態(tài)送入P2 口 P3=P1; // 將 P1 口狀態(tài)送入P3 口
上傳時(shí)間: 2013-10-26
上傳用戶:離殤
一、 main.c(35): warning: #128-D: loop is not reachable from preceding code 原因,前面有一個(gè)while(1){ …….} 二、 main.c(54): warning: #1-D: last line of file ends without a newline 少了一個(gè)回車在}之后
上傳時(shí)間: 2014-12-26
上傳用戶:sjb555
單片機(jī)c語(yǔ)言學(xué)習(xí)和單片機(jī)制作資料: 函數(shù)的使用和熟悉 實(shí)例3:用單片機(jī)控制第一個(gè)燈亮 實(shí)例4:用單片機(jī)控制一個(gè)燈閃爍:認(rèn)識(shí)單片機(jī)的工作頻率 實(shí)例5:將 P1口狀態(tài)分別送入P0、P2、P3口:認(rèn)識(shí)I/O口的引腳功能 實(shí)例6:使用P3口流水點(diǎn)亮8位LED 實(shí)例7:通過對(duì)P3口地址的操作流水點(diǎn)亮8位LED 實(shí)例8:用不同數(shù)據(jù)類型控制燈閃爍時(shí)間 實(shí)例9:用P0口、P1 口分別顯示加法和減法運(yùn)算結(jié)果 實(shí)例10:用P0、P1口顯示乘法運(yùn)算結(jié)果 實(shí)例11:用P1、P0口顯示除法運(yùn)算結(jié)果 實(shí)例12:用自增運(yùn)算控制P0口8位LED流水花樣 實(shí)例13:用P0口顯示邏輯"與"運(yùn)算結(jié)果 實(shí)例14:用P0口顯示條件運(yùn)算結(jié)果 實(shí)例15:用P0口顯示按位"異或"運(yùn)算結(jié)果 實(shí)例16:用P0顯示左移運(yùn)算結(jié)果 實(shí)例17:"萬能邏輯電路"實(shí)驗(yàn) 實(shí)例18:用右移運(yùn)算流水點(diǎn)亮P1口8位LED 實(shí)例19:用if語(yǔ)句控制P0口8位LED的流水方向 實(shí)例20:用swtich語(yǔ)句的控制P0口8位LED的點(diǎn)亮狀態(tài) 實(shí)例21:用for語(yǔ)句控制蜂鳴器鳴笛次數(shù) 實(shí)例22:用while語(yǔ)句控制LED 實(shí)例23:用do-while語(yǔ)句控制P0口8位LED流水點(diǎn)亮 實(shí)例24:用字符型數(shù)組控制P0口8位LED流水點(diǎn)亮 實(shí)例25: 用P0口顯示字符串常量 實(shí)例26:用P0 口顯示指針運(yùn)算結(jié)果 實(shí)例27:用指針數(shù)組控制P0口8位LED流水點(diǎn)亮 實(shí)例28:用數(shù)組的指針控制P0 口8 位LED流水點(diǎn)亮 實(shí)例29:用P0 、P1口顯示整型函數(shù)返回值 實(shí)例30:用有參函數(shù)控制P0口8位LED流水速度 實(shí)例31:用數(shù)組作函數(shù)參數(shù)控制流水花樣 實(shí)例32:用指針作函數(shù)參數(shù)控制P0口8位LED流水點(diǎn)亮 實(shí)例33:用函數(shù)型指針控制P1口燈花樣 實(shí)例34:用指針數(shù)組作為函數(shù)的參數(shù)顯示多個(gè)字符串
上傳時(shí)間: 2013-10-21
上傳用戶:llandlu
為提高溫度測(cè)量效率,降低系統(tǒng)的成本,擴(kuò)展傳輸距離,設(shè)計(jì)出一種新型溫度采集系統(tǒng)。單片機(jī)通過控制具有單總線方式的溫度傳感器DS18B20實(shí)現(xiàn)對(duì)溫度的測(cè)量,同時(shí)單片機(jī)通過控制具有單總線方式300~450MHz頻率范圍內(nèi)的MAX7044與MAX7033無線發(fā)射與接收芯片實(shí)現(xiàn)溫度數(shù)據(jù)的無線傳輸。與傳統(tǒng)溫度采集系統(tǒng)相比,該系統(tǒng)利用單總線方式連接,采用無線傳輸方式實(shí)現(xiàn)遠(yuǎn)距離通信,易于系統(tǒng)的集成與擴(kuò)展。實(shí)驗(yàn)結(jié)果表明,該系統(tǒng)結(jié)構(gòu)簡(jiǎn)單、方便移植,能夠同時(shí)實(shí)現(xiàn)多達(dá)上百點(diǎn)溫度的測(cè)量與500m范圍的傳輸。 Abstract: To improve the temperature measurement efficiency and reduce system cost,expansion of transmission distance,a new type of temperature acquisition system is designed.Microcontroller controlled temperature sensor DS18B20which has a single-bus achieves temperature measurement,while microcontroller by controlled the MAX7044and MAX7033chip with a single-bus and having300~450MHz radiofrequency to achieve the wireless transmission of temperature data.Compared with conventional temperature acquisition system,the system uses single-bus connected,and uses wireless transmission means to achieve long-distance communications,easy-to-system integration and expansion.The experimental results show that the system is simple,convenient transplantation,and can be implemented in as many as a hundred-point temperature measure-ment and the transmission range of500meters.
標(biāo)簽: 單總線 無線溫度 采集 系統(tǒng)設(shè)計(jì)
上傳時(shí)間: 2013-10-29
上傳用戶:515414293
NXP Semiconductor designed the LPC2400 microcontrollers around a 16-bit/32-bitARM7TDMI-S CPU core with real-time debug interfaces that include both JTAG andembedded Trace. The LPC2400 microcontrollers have 512 kB of on-chip high-speedFlash memory. This Flash memory includes a special 128-bit wide memory interface andaccelerator architecture that enables the CPU to execute sequential instructions fromFlash memory at the maximum 72 MHz system clock rate. This feature is available onlyon the LPC2000 ARM Microcontroller family of products. The LPC2400 can execute both32-bit ARM and 16-bit Thumb instructions. Support for the two Instruction Sets meansEngineers can choose to optimize their application for either performance or code size atthe sub-routine level. When the core executes instructions in Thumb state it can reducecode size by more than 30 % with only a small loss in performance while executinginstructions in ARM state maximizes core performance.
上傳時(shí)間: 2013-11-15
上傳用戶:zouxinwang
C51 中的關(guān)鍵字關(guān)鍵字 用途 說明auto 存儲(chǔ)種類說明 用以說明局部變量,缺省值為此break 程序語(yǔ)句 退出最內(nèi)層循環(huán)case 程序語(yǔ)句 Switch 語(yǔ)句中的選擇項(xiàng)char 數(shù)據(jù)類型說明 單字節(jié)整型數(shù)或字符型數(shù)據(jù)const 存儲(chǔ)類型說明 在程序執(zhí)行過程中不可更改的常量值continue 程序語(yǔ)句 轉(zhuǎn)向下一次循環(huán)default 程序語(yǔ)句 Switch 語(yǔ)句中的失敗選擇項(xiàng)do 程序語(yǔ)句 構(gòu)成do..while 循環(huán)結(jié)構(gòu)double 數(shù)據(jù)類型說明 雙精度浮點(diǎn)數(shù)else 程序語(yǔ)句 構(gòu)成if..else 選擇結(jié)構(gòu)enum 數(shù)據(jù)類型說明 枚舉extern 存儲(chǔ)種類說明 在其他程序模塊中說明了的全局變量flost 數(shù)據(jù)類型說明 單精度浮點(diǎn)數(shù)for 程序語(yǔ)句 構(gòu)成for 循環(huán)結(jié)構(gòu)goto 程序語(yǔ)句 構(gòu)成goto 轉(zhuǎn)移結(jié)構(gòu)if 程序語(yǔ)句 構(gòu)成if..else 選擇結(jié)構(gòu)int 數(shù)據(jù)類型說明 基本整型數(shù)long 數(shù)據(jù)類型說明 長(zhǎng)整型數(shù)register 存儲(chǔ)種類說明 使用CPU 內(nèi)部寄存的變量return 程序語(yǔ)句 函數(shù)返回short 數(shù)據(jù)類型說明 短整型數(shù)signed 數(shù)據(jù)類型說明 有符號(hào)數(shù),二進(jìn)制數(shù)據(jù)的最高位為符號(hào)位sizeof 運(yùn)算符 計(jì)算表達(dá)式或數(shù)據(jù)類型的字節(jié)數(shù)static 存儲(chǔ)種類說明 靜態(tài)變量struct 數(shù)據(jù)類型說明 結(jié)構(gòu)類型數(shù)據(jù)swicth 程序語(yǔ)句 構(gòu)成switch 選擇結(jié)構(gòu)typedef 數(shù)據(jù)類型說明 重新進(jìn)行數(shù)據(jù)類型定義union 數(shù)據(jù)類型說明 聯(lián)合類型數(shù)據(jù)unsigned 數(shù)據(jù)類型說明 無符號(hào)數(shù)數(shù)據(jù)void 數(shù)據(jù)類型說明 無類型數(shù)據(jù)volatile 數(shù)據(jù)類型說明 該變量在程序執(zhí)行中可被隱含地改變while 程序語(yǔ)句 構(gòu)成while 和do..while 循環(huán)結(jié)構(gòu)ANSIC 標(biāo)準(zhǔn)關(guān)鍵字關(guān)鍵字 用途 說明bit 位標(biāo)量聲明 聲明一個(gè)位標(biāo)量或位類型的函數(shù)sbit 位標(biāo)量聲明 聲明一個(gè)可位尋址變量
標(biāo)簽: C51
上傳時(shí)間: 2013-10-08
上傳用戶:waves_0801
AT89C2051驅(qū)動(dòng)步進(jìn)電機(jī)的電路和源碼:AT89C2051驅(qū)動(dòng)步進(jìn)電機(jī)的電路和源碼 程序:stepper.c stepper.hex/* * STEPPER.C * sweeping stepper's rotor cw and cww 400 steps * Copyright (c) 1999 by W.Sirichote */#i nclude c:\mc5151io.h /* include i/o header file */ #i nclude c:\mc5151reg.hregister unsigned char j,flag1,temp; register unsigned int cw_n,ccw_n;unsigned char step[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90} #define n 400/* flag1 mask byte 0x01 run cw() 0x02 run ccw() */main(){ flag1=0; serinit(9600); disable(); /* no need timer interrupt */ cw_n = n; /* initial step number for cw */ flag1 |=0x01; /* initial enable cw() */while(1){ { tick_wait(); /* wait for 10ms elapsed */energize(); /* round-robin execution the following tasks every 10ms */ cw(); ccw(); } }}cw(){ if((flag1&0x01)!=0) { cw_n--; /* decrement cw step number */ if (cw_n !=0) j++; /* if not zero increment index j */ else {flag1&=~0x01; /* disable cw() execution */ ccw_n = n; /* reload step number to ccw counter */ flag1 |=0x02; /* enable cww() execution */ } }
上傳時(shí)間: 2013-11-21
上傳用戶:boyaboy
The PCA9516 is a BiCMOS integrated circuit intended forapplication in I2C and SMBus systems.while retaining all the operating modes and features of the I2Csystem, it permits extension of the I2C-bus by buffering both the data(SDA) and the clock (SCL) lines, thus enabling five buses of 400 pF.The I2C-bus capacitance limit of 400 pF restricts the number ofdevices and bus length. Using the PCA9516 enables the systemdesigner to divide the bus into five segments off of a hub where anysegment to segment transition sees only one repeater delay.
標(biāo)簽: 5channel 9516 PCA I2C
上傳時(shí)間: 2013-11-21
上傳用戶:q123321
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1