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: mbed
Fork of i2ctry by
i2c.cpp
00001 #include "mbed.h" 00002 #include "MMA8451Q.h" 00003 00004 PinName const SDA = PTE25; 00005 PinName const SCL = PTE24; 00006 DigitalOut myled(LED2); 00007 00008 #define MMA8451_I2C_ADDRESS (0x1d<<1) 00009 00010 00011 int main(){ 00012 00013 MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); 00014 00015 while (true) { 00016 float x, y, z; 00017 x = abs(acc.getAccX()); 00018 y = abs(acc.getAccY()); 00019 z = abs(acc.getAccZ()); 00020 00021 if (x>0.5) 00022 { 00023 myled = 0; 00024 } 00025 else 00026 { 00027 myled = 1; 00028 } 00029 printf("%f",x); 00030 } 00031 00032 }
Generated on Sun Jul 17 2022 20:57:57 by
1.7.2
