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 "MMA8451Q.h" 00003 00004 #define MMA8451_I2C_ADDRESS (0x1d<<1) 00005 #define ON 0 00006 #define OFF !ON 00007 00008 //Setup the interrupts for the MMA8451Q 00009 InterruptIn accInt1(PTA14); 00010 InterruptIn accInt2(PTA15);//not used in this prog but this is the other int from the accelorometer 00011 00012 uint8_t togstat=0;//Led status 00013 DigitalOut bled(LED_BLUE); 00014 00015 00016 void tapTrue(void){ 00017 if(togstat == 0){ 00018 togstat = 1; 00019 bled=ON; 00020 } else { 00021 togstat = 0; 00022 bled=OFF; 00023 } 00024 00025 } 00026 00027 00028 int main(void) { 00029 00030 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);//accelorometer instance 00031 00032 acc.setDoubleTap();//Setup the MMA8451Q to look for a double Tap 00033 accInt1.rise(&tapTrue);//call tapTrue when an interrupt is generated on PTA14 00034 00035 while (true) { 00036 //Interrupt driven so nothing in main loop 00037 } 00038 }
Generated on Tue Jul 26 2022 11:43:04 by
1.7.2