《霍尔传感器实验C程序.docx》由会员分享,可在线阅读,更多相关《霍尔传感器实验C程序.docx(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、/实验四十五霍尔传感器实验#include nreg51.hn#include nabsacc.hn#define LEDLen 6位控制口/段控制口键盘读入口xdata unsigned char OUTBIT _at_ 0x8002;/xdata unsigned char OUTSEG _at_ 0x8004;xdata unsigned char IN _at_ 0x8001;/unsigned char LEDBufLEDLen; / 显示缓冲code unsigned char LEDMAP= / 八段管显示码 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d,
2、 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71);void delay(unsigned char CNT)(unsigned char i;while (CNT- !=0)for (i=50; i !=0; i);) void DisplayLED()(unsigned char i;unsigned char Pos;unsigned char LED;/从左边开始显示/关所有八段管/显示一位八段管/显示下一位/关所有八段管Pos = 0x20;for (i = 0; i = 1;)OUTBIT = 0;void main()unsigned char i = 0,j; TO计数方式long int n;TMOD = 0X05;THO = 0;TLO = 0;TR0= 1;while(l)n = TH0*256+TL0;for(j=0;j6;j+)(LEDBuf5-j=LEDMAPn%10; n=n/10;)/显示计数值DisplayLED();