求助各位大神!!!怎么让ADXL345 加速度传感器可以在 串口助手上显示出来 下面是我 仿编的 程序 串口上不能显示 加速度的变化值
- # include "sys.h"
- # include "delay.h"
- # include "printf.h"
- # include "adxl345.h"
- # include "usart.h"
- # include "led.h"
- # include "key.h"
- void Delay (u32 i)
- {
- while(i--);
- }
-
- int main(void)
- {
- u8 key;
- u8 t=0;
- double x,y,z;
- double angx,angy,angz;
- delay_init();
- LED_Init();
- KEY_Init();
- printf_init();
- I2C_INIT();
- ADXL345_Init();
- while(1)
- {
- if(t%10==0)
- {
-
- ADX_GetXYZ_Value((short*)&x, (short*)&y,(short*) &z);
- printf("x:%f \n",x);
- printf("y: %f \n",y);
- printf("z: %f\n",z);
- Delay(6000000);
-
- angx=ADXL345_Get_Angle(x,y,z,1);
- angy=ADXL345_Get_Angle(x,y,z,2);
- angz=ADXL345_Get_Angle(x,y,z,0);
- printf("角度x%f\r\n",angx);
- printf("角度y%f\r\n",angy);
- printf("角度z%f\r\n",angz);
- Delay(6000000);
- }
- key=KEY_Scan(0);
- if(key==KEY_UP)
- {
- LED1=0;
- ADXL345_AUTO_Adjust((short*)&x, (short*)&y, (short*)&z);
- LED1=1;
- }
- delay_ms(10);
- t++;
- if(t==20)
- {
- t=0;
- LED0=!LED0;
- }
- }
- }
复制代码 |