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 "ADXL345sb.h" 00003 00004 DigitalOut myled(LED1); 00005 ADXL345sb accel(p5, p6, p7, p8); // mosi, miso, sclk, ncs 00006 00007 Serial pc(USBTX, USBRX); // tx, rx 00008 00009 int main() { 00010 00011 float readings[3]; 00012 00013 while(1) { 00014 wait(0.1); 00015 00016 accel.adxlwrite(DATA_FORMAT,0x01); 00017 accel.adxlwrite(POWER_CTL ,0x08); 00018 00019 accel.adxlreadXYZ(readings); 00020 00021 float angleX = acos(readings[0]); 00022 float angleY = acos(readings[1]); 00023 float angleZ = acos(readings[2]); 00024 00025 if(isnan(angleX)) 00026 angleX = 0; 00027 if(isnan(angleY)) 00028 angleY = 0; 00029 if(isnan(angleZ)) 00030 angleZ = 0; 00031 00032 printf("%f,%f,%f,\r\n",angleX,angleY,angleZ); 00033 } 00034 }
Generated on Mon Jul 18 2022 03:42:13 by
1.7.2