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 DigitalOut led(LED_RED); 00005 InterruptIn accel_int_pin(PTC13); //FRDM-K64F 00006 Serial pc(USBTX, USBRX); 00007 FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); //FRDM-K64F 00008 00009 uint8_t motion_detected; 00010 00011 void accel_interrupt(void) 00012 { 00013 led = 0; //turn led on 00014 motion_detected = 1; 00015 fxos.clear_int(); 00016 } 00017 00018 int main() 00019 { 00020 pc.baud(9600); 00021 00022 pc.printf("ready to rock!\n"); 00023 00024 motion_detected = 0; 00025 accel_int_pin.fall(&accel_interrupt); 00026 accel_int_pin.mode(PullUp); 00027 00028 led = 1; //turn led off 00029 00030 fxos.config_int(); //enabled interrupts from accelerometer 00031 fxos.config_feature(); //turn on motion detection 00032 fxos.enable(); //enable accelerometer 00033 00034 while (true) { 00035 00036 if(motion_detected == 1) 00037 { 00038 wait(1); 00039 00040 led = 1; //turn led off 00041 motion_detected = 0; 00042 00043 sleep(); 00044 } 00045 } 00046 }
Generated on Wed Jul 13 2022 06:34:16 by
1.7.2