Configures accel to trigger interrupt pin when motion detected, puts MCU to sleep, when motion happens, it wakes the MCU.
Revision 2:fe9b68d45cf5, committed 2016-09-03
- 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
--- 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
--- /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
--- 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