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.
Fork of MMA8491Q by
main.cpp
00001 /** 00002 * example MMA8491Q accelerometer on Sensor Evaluation Board 00003 * with the FRDM-KL25Z processor board 00004 */ 00005 #include "mbed.h" 00006 #include "MMA8491Q.h" 00007 00008 #define MMA8451_I2C_ADDRESS (0x55<<1) 00009 00010 Serial pc(USBTX, USBRX); 00011 00012 int main(void) { 00013 00014 MMA8491Q acc(PTE0, PTE1, MMA8451_I2C_ADDRESS, PTA13); 00015 00016 PwmOut rled(LED_RED); 00017 PwmOut gled(LED_GREEN); 00018 PwmOut bled(LED_BLUE); 00019 00020 float accX; 00021 float accY; 00022 float accZ; 00023 float accData[3]; 00024 00025 while (true) { 00026 /* acc.getAccAllAxis(accData); 00027 accX = accData[0]; 00028 accY = accData[1]; 00029 accZ = accData[2]; 00030 */ 00031 accX = acc.getAccX(); 00032 accY = acc.getAccY(); 00033 accZ = acc.getAccZ(); 00034 00035 /* rled = 1.0 - abs(accX); 00036 gled = 1.0 - abs(accX); 00037 bled = 1.0 - abs(accX); 00038 */ 00039 pc.printf("X = %5.3f", accX); 00040 pc.printf(" Y = %5.3f", accY); 00041 pc.printf(" Z = %5.3f\r\n", accZ); 00042 00043 wait(1.0); 00044 } 00045 }
Generated on Thu Jul 14 2022 01:36:16 by
1.7.2
