计步器 c语言,ADXL345单片机计步器程序

#include

#include

#include"1602.h"

#include  

#define        SlaveAddress   0xA6          //1010 0110    定义器件在IIC总线中的从地址,根据ALT  ADDRESS地址引脚不同修改

//ALT  ADDRESS引脚接地时地址为0xA6,接电源时地址为0x3A 0011 1010

sbit sclk=P0^0;

sbit sda=P0^1;

float  dis_datax,dis_datay,dis_dataz,acc,acc1=1000;

uchar BUF[8];

uchar wan, qian, bai, shi ,ge,flag,miao,miao1,n;

uint count;

void conversion(uint temp_data)

{

wan=temp_data/10000+0x30 ;

temp_data=temp_data%10000;   //取余运算

qian=temp_data/1000+0x30 ;

temp_data=temp_data%1000;    //取余运算

bai=temp_data/100+0x30   ;

temp_data=temp_data%100;     //取余运算                                 -e----------------eee-e

shi=temp_data/10+0x30    ;

temp_data=temp_data%10;      //取余运算

ge=temp_data+0x30;

}

void delay6us()                 //6us延时函数

{

_nop_();        _nop_();

}

void delay_ms(uint n)       //N ms延时函数

{

uint x,y;

for(x=n;x>0;x--)

for(y=110;y>0;y--);

}

/

void ADXL345_Start()

{

sda = 1;                    //拉高数据线

sclk = 1;                    //拉高时钟线

delay6us();                 //延时

sda = 0;                    //产生下降沿

delay6us();                 //延时

sclk = 0;                    //拉低时钟线

}

void ADXL345_Stop()

{

sda = 0;                    //拉低数据线

sclk = 1;                    //拉高时钟线

delay6us();                 //延时

sda = 1;                    //产生上升沿

delay6us();                 //延时

<
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于3轴加速度计ADXL345的全功能计步器设计 摘 要 计步器是一种颇受欢迎的日常锻炼进度监控器,可以激励人们挑战自己,增强体质, 帮助瘦身。早期设计利用加重的机械开关检测步伐,并带有一个简单的计数器。晃动这 些装置时,可以听到有一个金属球来回滑动,或者一个摆锤左右摆动敲击挡块。 计步器功能可以根据计算人的运动情况来分析人体的健康状况。而人的运动情况可以 通过很多特性来进行分析。比如人在运动时会产生加速度。本文介绍了利用人运动时产 生加速度变化来检测步数的计步器实现方案,利用具有体积小,功耗低,三轴高精度加 速度传感器ADXL345,芯片内部即可把数据采集来的数据处理为数字数据,采集到加速度 数据以后加以适当的算法就可以实现计步功能。本文设计了一款基于加速度传感器ADXL 345的计步器。详细介绍了计步器的软件算法的实同时芯片中还集成了SPI和I²C接口,可 以方便地将数据传输到主控芯片。该系统设计简单,实现方便。该芯片也可以扩展到其 它需要测量加速度的应用场合,具有非常广阔的应用前景。 关键字:计步器 加速度传感器 ADXL345 低功耗 Based on three accelerometer ADXL345 company-wide functional pedometer design Abstract Pedometer is a popular daily exercise, can inspire people progress monitors challenge yourself, enhanced physique, help thin body. Early design of mechanical switch detection using aggravated with a simple steps, and the counter. When shaking these devices, can hear a metal ball slide back and forth, or a pendulum swings around percussion block pieces. Pedometer function can according to the calculated a people's movement situation to analyze a healthy condition of body. But the person's movements can pass a lot of properties for analysis. Such as people in motion produces acceleration. This paper describes the use of people move to detect changes generated when the acceleration of steps, utilization of implementation scheme pedometer, small size, low power consumption, high ADXL345 three axis acceleration sensor, chip can put the data acquisition to internal data processing for the digital data acquisition to acceleration data, after appropriate algorithm can achieve plan step function. This paper introduces the design of a paragraph of the pedometer ADXL345 based on acceleration sensor. Introduces the software algorithm real pedometer while the SPI has integrated chip I²C interface, and I can be conveniently data transmission to the main control chip. The system is simple in design, realization convenient. The chip can also extend to other need to measure the applications, the acceleration is very broad appli

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值