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.
Dependencies: MAG3110 MMA8451Q TSI mbed
main.cpp
00001 #include "mbed.h" 00002 #include "MMA8451Q.h" 00003 #include "MAG3110.h" 00004 00005 #define MMA8451_I2C_ADDRESS (0x1d<<1) 00006 00007 Serial pc(USBTX,USBRX); 00008 00009 int main(void) { 00010 00011 MAG3110 mag(PTE0,PTE1,&pc); 00012 //mag.setCalibration(64140,64550,900,1145); 00013 00014 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); 00015 PwmOut rled(LED_RED); 00016 PwmOut gled(LED_GREEN); 00017 PwmOut bled(LED_BLUE); 00018 00019 int x,y,z; 00020 int xnew = 0; 00021 00022 while (true) { 00023 mag.getValues(&x, &y, &z); 00024 pc.printf("%d %d %d\n\r", x, y, z); 00025 00026 float xnew = x; 00027 float ynew = y; 00028 float znew = z; 00029 00030 rled = 1.0 - abs(float(x)/65535); 00031 gled = 1.0 - abs(float(y)/65535); 00032 bled = 1.0 - abs(float(z)/65535); 00033 00034 00035 //rled = 1.0 - abs(acc.getAccX()); 00036 //gled = 1.0 - abs(acc.getAccY()); 00037 //bled = 1.0 - abs(acc.getAccZ()); 00038 //mag.getValues(&x,&y,&z); 00039 //pc.printf("%f\n\r",mag.getHeading()); 00040 wait(0.1); 00041 } 00042 }
Generated on Fri Jul 15 2022 19:28:24 by
1.7.2