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: BSP_B-L475E-IOT01 mbed
main.cpp
00001 #include "mbed.h" 00002 00003 // Sensors drivers present in the BSP library 00004 #include "stm32l475e_iot01_accelero.h" 00005 00006 DigitalOut led(LED1); 00007 DigitalOut led2(LED2); 00008 DigitalOut led3(LED3); 00009 00010 int main() 00011 { 00012 int16_t pDataXYZ[3] = {0}; 00013 00014 00015 BSP_ACCELERO_Init(); 00016 00017 while(1) { 00018 00019 // Z Horizontal LED1, X short LED3, Y long LED2 00020 BSP_ACCELERO_AccGetXYZ(pDataXYZ); 00021 led = 0; 00022 led2 = 0; 00023 led3 = 0; 00024 if (abs(pDataXYZ[0]) > 900) { 00025 led3 = 1; 00026 } else if (abs(pDataXYZ[1]) > 900) { 00027 led2 = 1; 00028 } else if (abs(pDataXYZ[2]) > 900) { 00029 led = 1; 00030 } else { 00031 led = 1; 00032 led2 = 1; 00033 led3 = 1; 00034 } 00035 00036 printf("\nACCELERO_X = %d\n", pDataXYZ[0]); 00037 printf("ACCELERO_Y = %d\n", pDataXYZ[1]); 00038 printf("ACCELERO_Z = %d\n", pDataXYZ[2]); 00039 00040 wait(1); 00041 00042 led = 0; 00043 led2 = 0; 00044 led3 = 0; 00045 00046 } 00047 }
Generated on Thu Jul 14 2022 10:56:33 by
1.7.2