Configures accel to trigger interrupt pin when motion detected, puts MCU to sleep, when motion happens, it wakes the MCU.

Dependencies:   FXOS8700CQ

Files at this revision

API Documentation at this revision

Comitter:
maclobdell
Date:
Sat Sep 03 16:44:41 2016 +0000
Parent:
1:bbe8471609d5
Commit message:
remove play song stuff. update to mbed-os library. added pins connections for Hexiwear

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r bbe8471609d5 -r fe9b68d45cf5 main.cpp
--- a/main.cpp	Fri Aug 12 15:15:25 2016 +0000
+++ b/main.cpp	Sat Sep 03 16:44:41 2016 +0000
@@ -4,12 +4,11 @@
 void play_song(void);
 
 DigitalOut led_red(LED_RED);
-//InterruptIn accel_int_pin(PTD1);   //FRDM-K26Z
-InterruptIn accel_int_pin(PTC13);  //FRDM-K64F
+//InterruptIn accel_int_pin(PTC13);  //ACCEL INT2, FRDM-K64F
+InterruptIn accel_int_pin(PTD13);  //ACCEL INT2, HEXIWEAR
 
-FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)  //FRDM-K64F
-
-DigitalOut sound_power_on(D7);
+//FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)  //FRDM-K64F
+FXOS8700CQ fxos(PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // SDA, SCL, (addr << 1)  //HEXIWEAR
 
 Serial pc(USBTX, USBRX);
 
@@ -23,7 +22,6 @@
     { 
         led_red = 0;  //turn led on
         motion_detected = 1;
-        //pc.printf("motion detected!\n");
     }
         
     fxos.clear_int(); 
@@ -42,7 +40,6 @@
     motion_detected = 0;
     accel_int_pin.fall(&accel_interrupt);
     led_red = 1;  //turn led off
-    sound_power_on = 0;
 
     accel_int_pin.mode(PullUp);
 
@@ -50,34 +47,18 @@
     fxos.config_feature();
     fxos.enable();
 
-    //why is there a separate fxos8700q library?  
-
-
     while (true) {
     
         if(motion_detected == 1)
         {
         
-            play_song();
-
+            pc.printf("motion detected!\n");
+            wait(1);            
             led_red = 1;  //turn led off
             motion_detected = 0;
         
-            sleep();            
+            deepsleep();            
         }
    }
 }
-
-void play_song(void)
-{
-  //turn on power to sound system
-  sound_power_on = 1;
-  
-  //wait for song to finish
-  wait(10);
-  
-  //turn off power to sound system
-  sound_power_on = 0;
-  
-    
-}   
\ No newline at end of file
+   
\ No newline at end of file
diff -r bbe8471609d5 -r fe9b68d45cf5 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sat Sep 03 16:44:41 2016 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#bdab10dc0f90748b6989c8b577771bb403ca6bd8
diff -r bbe8471609d5 -r fe9b68d45cf5 mbed.bld
--- a/mbed.bld	Fri Aug 12 15:15:25 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/da0ca467f8b5
\ No newline at end of file