Use accelerometer to interrupt.
Dependencies: mbed SDFileSystem
Fork of shomberg_hw_7 by
main.cpp
- Committer:
- rshomberg
- Date:
- 2018-11-08
- Revision:
- 24:9264fbd225d0
- Parent:
- 23:61d87ea09c26
- Child:
- 25:820fe1232054
File content as of revision 24:9264fbd225d0:
/** Temperature Sensor and Logging for hw7 main.cpp Purpose: Read signal from TMP36 connected to pin20 Toggle switch connected to pin07 activates SD logging Log: Time Elasped, Current Voltage, Current Temp, Delta Temp Finish log -> save file and send to USB serial port if accelerometer records transient, 3 sec of data is recorded @author Russell Shomberg @created 2018-11=01 @revised 2018-11-07 @version 0.0 Issues: */ // PIN CONFIGURATION #define PIN_INTERRUPT p14 // INCLUDES #include "mbed.h" #include "data_log.h" #include "OCE360Input.h" #include "SDFileSystem.h" // OUTPUTS Serial pc(USBTX, USBRX); // for debugging int DigitalOut interrupt(PIN_INTERRUPT); // VARIABLES Timer t; float starting_temp; // Initialize SDFileSystem SDFileSystem sd(PIN_SD_MOSI,PIN_SD_MISO,PIN_SD_SCLK,PIN_SD_CS,"sd"); int main() { // Take initial readings starting_temp = convert_mV_to_temp(read_sensor()); //Initialize Timer t.start(); // Mount the sd sd.mount(); while(1) { while(!read_switch()) { wait(1); // nothing happens when the switch is off } temp_log tempLog = temp_log(starting_temp); // start a loop that logging // exiting this loop will initialize data save procedures while(read_switch()) { // Main loop for logging tempLog.write_data(t.read()); wait(1); } tempLog.write_to_pc(); } }