Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "HEPTA_EPS.h" 00003 00004 Serial pc(USBTX,USBRX); 00005 HEPTA_EPS eps(p16,p26); 00006 I2C i2c(p28, p27); 00007 00008 const int addr_accel_gyro = 0xD0; 00009 char cmd[2]; 00010 short int xl,xh,yl,yh,zl,zh; 00011 int main() 00012 { 00013 i2c.frequency(100000); 00014 cmd[0]=0x6B; 00015 cmd[1]=0x00; 00016 i2c.write(addr_accel_gyro,cmd,2); 00017 cmd[0] = 0x37; 00018 cmd[1] = 0x02; 00019 i2c.write(addr_accel_gyro,cmd,2); 00020 i2c.stop(); 00021 while(1) { 00022 i2c.start(); 00023 i2c.write(addr_accel_gyro); 00024 i2c.write(0x3b);//read adress 00025 i2c.start(); 00026 i2c.write(addr_accel_gyro|0x01); 00027 xh = i2c.read(0); 00028 i2c.stop(); 00029 i2c.start(); 00030 i2c.write(addr_accel_gyro); 00031 i2c.write(0x3c); 00032 i2c.start(); 00033 i2c.write(addr_accel_gyro|0x01); 00034 xl = i2c.read(0); 00035 i2c.stop(); 00036 double acc_ax = short((xh<<8) | (xl)); 00037 double AX = (acc_ax)*2/32768*9.81; 00038 pc.printf("AX = %f\r\n",AX); 00039 wait(0.5); 00040 } 00041 }
Generated on Thu Jul 14 2022 02:39:12 by
1.7.2