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.
Dependencies: X_NUCLEO_IKS01A2
main.cpp
00001 /*---------------------------------------------------------------------------- 00002 LAB EXERCISE - Environmental sensors measurements 00003 ---------------------------------------- 00004 In this exercise we will read the environmental sensors on the Nucleo sensors shield (X-NUCLEO-IKS01A1) 00005 with the help of the ST Nucleo Sensor Shield library which is compatible with the MBED API. 00006 Then we will send the measurements via USB to our PC using serial communication. 00007 We can then display the results using a terminal emulation program (e.g. Termite). 00008 00009 At the same time the program blinks the on board LED to show alivness. 00010 00011 00012 GOOD LUCK! 00013 *----------------------------------------------------------------------------*/ 00014 00015 #include "mbed.h" 00016 #include "x_cube_mems.h" 00017 00018 // Create a DigitalOut objects for the LED 00019 00020 // Create a Serial objects to communicate via USB 00021 00022 // Create 2 Ticker objects for recurring interrupts. One for blink a LED and the other one to update the sensor lectures periodicly 00023 00024 // Initialize variables 00025 00026 // Handler for the aliveness LED; to be called every 0.5s 00027 00028 // Handler for the measurements update; rise a flag every 3 seconds 00029 00030 00031 00032 int main() { 00033 00034 /* Create sensor shield object */ 00035 00036 /* Attach a function to be called by the Ticker objects at a specific interval in seconds */ 00037 00038 00039 while(1) { 00040 00041 /* Check for the measurements update flag */ 00042 00043 /* Read the environmental sensors */ 00044 00045 /* Calculate temperature in Fahrenheit and Kelvins */ 00046 00047 /*Send data through serial communication */ 00048 00049 /* Turn down the measurements update flag */ 00050 00051 /*Wait for interrupts*/ 00052 } 00053 } 00054 // *******************************ARM University Program Copyright � ARM Ltd 2015*************************************
Generated on Mon Jul 25 2022 11:33:31 by
1.7.2