Эх сурвалжийг харах

fix the serial initialize of demo code

953308023@qq.com 4 жил өмнө
parent
commit
cc3c991b30

+ 1 - 1
examples/FreeFallDetect/FreeFallDetect.ino

@@ -40,6 +40,7 @@ uint16_t detectCount = 0;
 
 void setup() {
     Serial.begin(9600);
+    while (!Serial);
     if (lsm6ds3.begin() != 0) {
         Serial.println("Device error");
     } else {
@@ -84,4 +85,3 @@ int config_free_fall_detect(void) {
 
     return error;
 }
-

+ 2 - 1
examples/HighLevelExample/HighLevelExample.ino

@@ -37,6 +37,7 @@ LSM6DS3 myIMU(I2C_MODE, 0x6A);    //I2C device address 0x6A
 void setup() {
     // put your setup code here, to run once:
     Serial.begin(9600);
+    while (!Serial);
     //Call .begin() to configure the IMUs
     if (myIMU.begin() != 0) {
         Serial.println("Device error");
@@ -72,4 +73,4 @@ void loop() {
     Serial.println(myIMU.readTempF(), 4);
 
     delay(1000);
-}
+}

+ 2 - 1
examples/LowLevelExample/LowLevelExample.ino

@@ -40,6 +40,7 @@ LSM6DS3Core myIMU(I2C_MODE, 0x6A);    //I2C device address 0x6A
 void setup() {
     //Init Serial port
     Serial.begin(9600);
+    while (!Serial);
 
     //Call .beginCore() to configure the IMU
     if (myIMU.beginCore() != 0) {
@@ -96,4 +97,4 @@ void loop() {
     Serial.println(errorsAndWarnings);
 
     delay(1000);
-}
+}

+ 1 - 1
examples/Pedometer/Pedometer.ino

@@ -39,6 +39,7 @@ LSM6DS3 pedometer(I2C_MODE, 0x6A);    //I2C device address 0x6A
 
 void setup() {
     Serial.begin(9600);
+    while (!Serial);
     if (pedometer.begin() != 0) {
         Serial.println("Device error");
     } else {
@@ -99,4 +100,3 @@ int config_pedometer(bool clearStep) {
 
     return errorAccumulator;
 }
-