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 // Defines for sensors I2C 00005 #define SDA PTE25 00006 #define SCL PTE24 00007 #define INT1 PTA14 00008 00009 // Define for LED 00010 #define LRED PTC7 00011 00012 MMA8451Q acc(SDA, SCL); 00013 Serial pc(USBTX, USBRX); 00014 Ticker t; // Periodical timer for reading sensors 00015 //InterruptIn drdy(INT1); 00016 DigitalOut myled(LRED); 00017 00018 void newdata() { 00019 int16_t accdata[3]; 00020 00021 myled = !myled; 00022 // Reads all accelerometer and magnetometer data, and also reads analog from FSR1 and FSR2 00023 acc.getAccAllAxis(accdata); 00024 // Now we transmit data 00025 pc.printf("%d,%d,%d\r\n", accdata[0], accdata[1], accdata[2]); 00026 } 00027 00028 int main() { 00029 char cmd; 00030 myled = 1; 00031 pc.baud(921600); // 176kbps ou mais 00032 //drdy.disable_irq(); 00033 //drdy.fall(&newdata); 00034 00035 while(1) { 00036 if(pc.readable()) { 00037 cmd = pc.getc(); 00038 if(cmd == '1') { 00039 t.attach(&newdata, 0.00125); // 800Hz samples 00040 //drdy.enable_irq(); 00041 } else if(cmd == '0') { 00042 t.detach(); 00043 //drdy.disable_irq(); 00044 myled = 1; 00045 } 00046 } 00047 } 00048 } 00049 00050 /* 00051 00052 */
Generated on Thu Jul 28 2022 02:49:17 by
1.7.2