标题:
单片机霍尔计数源程序
[打印本页]
作者:
123456888
时间:
2018-12-18 10:46
标题:
单片机霍尔计数源程序
单片机源程序如下:
//开发板+ 44E霍尔开关元件 实现
//功能: 实现利用STC89单片机P33引脚上的霍尔开关引发P33引脚的中断,
//实现计数功能,所计数据显示在LCD显示屏上
//实验时间第12-13周
//预编译
#include <reg52.h>
#include "LCD.h"
#include "hall.h"
#define NUM_LEN 5 //定义显示长度,共5位,即最大值99999=100000-1,与hall.c文件中对应
//变量声明
unsigned int countN = 0;
unsigned int oriCountN = -1;
//主函数
void main()
{
unsigned char str1[] = " Hall Counter ";
unsigned char str2[] = " ";
unsigned char i;
unsigned int temp;
EA=1; //开启总中断
hallInit(); //霍尔初始化
InitLcd1602();
LcdShowStr(0, 0, str1);
LcdShowStr(0, 1, str2);
while(1)
{
if(oriCountN != countN)
{
temp = countN ;
oriCountN = countN;
//以下用于刷新显示
//将各位上的数字转化为相应字符串
i = 1;
do
{
str2[NUM_LEN-i] = 0x30 + temp % 10;
temp /= 10;
i++;
}while(i<=NUM_LEN);
//如果有前置的零,则改为空格
i=0;
while(i<NUM_LEN)
{
if(str2[i] == '0')
str2[i] = ' ';
else
break;
i++;
}
LcdShowStr(0, 1, str2);
}
}
}
复制代码
所有资料51hei提供下载:
霍尔计数1下发.7z
(21.73 KB, 下载次数: 13)
2018-12-18 10:45 上传
点击文件名下载附件
123
下载积分: 黑币 -5
作者:
admin
时间:
2018-12-18 17:40
补全原理图或者详细说明一下电路连接即可获得100+黑币
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1