标题:
霍尔计数器单片机程序(基于金沙滩开发板+ 44E霍尔开关元件 实现)
[打印本页]
作者:
伊娃
时间:
2018-11-29 10:20
标题:
霍尔计数器单片机程序(基于金沙滩开发板+ 44E霍尔开关元件 实现)
//本项目基于金沙滩开发板+ 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);
}
}
}
复制代码
原理图在
http://www.51hei.com/bbs/dpj-108286-1.html
霍尔计数1.7z
2018-11-29 10:20 上传
点击文件名下载附件
下载积分: 黑币 -5
21.73 KB, 下载次数: 36, 下载积分: 黑币 -5
基于金沙滩开发板+ 44E霍尔开关元件 实现
作者:
45454545x
时间:
2018-12-17 09:37
hallInit(); //霍尔初始化
这个的初始化要怎么做呢??
作者:
wa51单片机
时间:
2018-12-18 10:58
没有.c文件哇,脑壳痛
作者:
tttt15
时间:
2018-12-18 14:24
.c文件呢
作者:
axzka
时间:
2019-1-6 22:13
hall.c呢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1