Skip to content

Commit f15a9e7

Browse files
biagiomsys_maker
authored and
sys_maker
committed
Fix for USB virtual serial port in sketches of CurieIMU library
Since Arduino/Genuino 101 uses USB native port, wait for the Serial port to open before executing the sketch to not lose serial data already sent to the Serial monitor Signed-off-by: Biagio Montaruli <[email protected]>
1 parent 1f0a5be commit f15a9e7

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

libraries/CurieIMU/examples/FreeFallDetect/FreeFallDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ unsigned long interruptsTime = 0; // get the time when free fall event is det
1616

1717

1818
void setup() {
19-
Serial.begin(9600);
20-
while(!Serial); // wait for the serial port to open
19+
Serial.begin(9600); // initialize Serial communication
20+
while(!Serial) ; // wait for serial port to connect.
2121

2222
/* Initialise the IMU */
2323
CurieIMU.begin();

libraries/CurieIMU/examples/MotionDetect/MotionDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ unsigned long loopTime = 0; // get the time since program started
1515
unsigned long interruptsTime = 0; // get the time when motion event is detected
1616

1717
void setup() {
18-
Serial.begin(9600);
19-
while(!Serial); // wait for the serial port to open
18+
Serial.begin(9600); // initialize Serial communication
19+
while(!Serial) ; // wait for serial port to connect.
2020

2121
/* Initialise the IMU */
2222
CurieIMU.begin();

libraries/CurieIMU/examples/ShockDetect/ShockDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
boolean blinkState = false; // state of the LED
1414

1515
void setup() {
16-
Serial.begin(9600);
17-
16+
Serial.begin(9600); // initialize Serial communication
17+
while(!Serial) ; // wait for serial port to connect..
1818
/* Initialise the IMU */
1919
CurieIMU.begin();
2020
CurieIMU.attachInterrupt(eventCallback);

libraries/CurieIMU/examples/StepCount/StepCount.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ long lastStepCount = 0; // step count on previous polling check
2525
boolean blinkState = false; // state of the LED
2626

2727
void setup() {
28-
Serial.begin(9600);
28+
Serial.begin(9600); // initialize Serial communication
29+
while(!Serial) ; // wait for serial port to connect.
2930
// pinMode(13, OUTPUT);
3031
// intialize the sensor:
3132
CurieIMU.begin();

libraries/CurieIMU/examples/TapDetect/TapDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "CurieIMU.h"
1212

1313
void setup() {
14-
Serial.begin(9600);
15-
14+
Serial.begin(9600); // initialize Serial communication
15+
while(!Serial) ; // wait for serial port to connect.
1616
// Initialise the IMU
1717
CurieIMU.begin();
1818
CurieIMU.attachInterrupt(eventCallback);

libraries/CurieIMU/examples/TapDoubleDetect/TapDoubleDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "CurieIMU.h"
1212

1313
void setup() {
14-
Serial.begin(9600);
15-
14+
Serial.begin(9600); // initialize Serial communication
15+
while(!Serial) ; // wait for serial port to connect.
1616
// Initialise the IMU
1717
CurieIMU.begin();
1818
CurieIMU.attachInterrupt(eventCallback);

libraries/CurieIMU/examples/ZeroMotionDetect/ZeroMotionDetect.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
boolean ledState = false; // state of the LED
1313
void setup() {
14-
Serial.begin(9600);
15-
while(!Serial); // wait for the serial port to open
14+
Serial.begin(9600); // initialize Serial communication
15+
while(!Serial) ; // wait for serial port to connect.
1616

1717
/* Initialise the IMU */
1818
CurieIMU.begin();

0 commit comments

Comments
 (0)