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 "FXOS8700CQ.h" 00003 00004 void play_song(void); 00005 00006 DigitalOut led_red(LED_RED); 00007 //InterruptIn accel_int_pin(PTC13); //ACCEL INT2, FRDM-K64F 00008 InterruptIn accel_int_pin(PTD13); //ACCEL INT2, HEXIWEAR 00009 00010 //FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1) //FRDM-K64F 00011 FXOS8700CQ fxos(PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // SDA, SCL, (addr << 1) //HEXIWEAR 00012 00013 Serial pc(USBTX, USBRX); 00014 00015 uint8_t motion_detected; 00016 uint8_t not_first_int; 00017 00018 void accel_interrupt(void) 00019 { 00020 00021 if(not_first_int == 1) 00022 { 00023 led_red = 0; //turn led on 00024 motion_detected = 1; 00025 } 00026 00027 fxos.clear_int(); 00028 00029 //first time around, set this to a 1 00030 not_first_int = 1; 00031 00032 } 00033 00034 int main() 00035 { 00036 pc.baud(9600); 00037 00038 pc.printf("ready to rock!\n"); 00039 not_first_int = 0; 00040 motion_detected = 0; 00041 accel_int_pin.fall(&accel_interrupt); 00042 led_red = 1; //turn led off 00043 00044 accel_int_pin.mode(PullUp); 00045 00046 fxos.config_int(); 00047 fxos.config_feature(); 00048 fxos.enable(); 00049 00050 while (true) { 00051 00052 if(motion_detected == 1) 00053 { 00054 00055 pc.printf("motion detected!\n"); 00056 wait(1); 00057 led_red = 1; //turn led off 00058 motion_detected = 0; 00059 00060 deepsleep(); 00061 } 00062 } 00063 } 00064
Generated on Sun Jul 17 2022 01:00:09 by
1.7.2