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 // accelerometer 00002 00003 #include "mbed.h" 00004 #include "MMA8451Q.h" //library for accelerometer 00005 00006 #define MMA8451_I2C_ADDRESS (0x1d<<1) //Address <<1 space indicates write 00007 00008 int main(void) { 00009 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); //create an object 00010 PwmOut rled(LED_RED); //create 3 objects for the leds pins 00011 PwmOut gled(LED_GREEN); 00012 PwmOut bled(LED_BLUE); 00013 00014 while (true) { 00015 rled = 1 - abs(acc.getAccX()); // abs() = absolute value 00016 gled = 1 - abs(acc.getAccY()); // getAccY = get Y-axis value 00017 bled = 1 - abs(acc.getAccZ()); // Substract 1 - absolute acceleration 00018 wait(0.1); //wait 100ms before new readings 00019 } 00020 } 00021
Generated on Sat Aug 6 2022 23:56:46 by
1.7.2