Skip to content

Commit 27a68de

Browse files
biagiomeriknyquist
authored andcommitted
Update sketches that use serial communication of different libraries
Improve sketches of CurieTime, CurieTimerOne, CurieSoftwareSerial, SPI and SerialFlash libraries that use Serial communication. Since Arduino/Genuino 101 uses USB native port, wait for the Serial port to open to not lose serial data already sent to the Serial monitor. Signed-off-by: Biagio Montaruli <biagio.hkr@gmail.com>
1 parent 39ef9ef commit 27a68de

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

libraries/CurieSoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void setup()
3434
// Open serial communications and wait for port to open:
3535
Serial.begin(115200);
3636
while (!Serial) {
37-
; // wait for serial port to connect. Needed for Leonardo only
37+
; // wait for serial port to connect. Needed for Native USB only
3838
}
3939

4040

libraries/CurieTime/examples/ReadTest/ReadTest.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include <CurieTime.h>
77

88
void setup() {
9-
while (!Serial);
10-
Serial.begin(9600);
9+
Serial.begin(9600); // initialize Serial communication
10+
while (!Serial); // wait for serial port to connect.
1111

1212
Serial.println("CurieTime Read Test");
1313
Serial.println("-------------------");

libraries/CurieTime/examples/SetTime/SetTime.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include <CurieTime.h>
77

88
void setup() {
9-
while (!Serial);
10-
Serial.begin(9600);
9+
Serial.begin(9600); // initialize Serial communication
10+
while(!Serial) ; // wait for serial port to connect.
1111

1212
// set the current time to 14:27:00, December 14th, 2015
1313
setTime(14, 27, 00, 14, 12, 2015);

libraries/CurieTimerOne/examples/CurieTimer1BlinkSpeed/CurieTimer1BlinkSpeed.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const int blinkPin = 13;
55
void setup(void)
66
{
77
CurieTimerOne.initialize(50000);
8-
Serial.begin(9600);
8+
Serial.begin(9600); // initialize Serial communication
9+
while(!Serial) ; // wait for serial port to connect.
910
}
1011

1112
void loop(void)

libraries/CurieTimerOne/examples/CurieTimer1Interrupt/CurieTimer1Interrupt.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void timedBlinkIsr() // callback function when interrupt is asserted
3838
void setup() {
3939

4040
#ifdef SERIAL_PORT_LOG_ENABLE
41-
Serial.begin(115200);
42-
while (!Serial); // wait for the serial monitor to open
41+
Serial.begin(115200); // initialize Serial communication
42+
while (!Serial); // wait for the serial monitor to open
4343
#endif
4444

4545
// Initialize pin 13 as an output - onboard LED.

libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ const int dataReadyPin = 6;
3838
const int chipSelectPin = 7;
3939

4040
void setup() {
41-
Serial.begin(9600);
41+
Serial.begin(9600); // initialize Serial communication
42+
while(!Serial) ; // wait for serial port to connect.
4243

4344
// start the SPI library:
4445
SPI.begin();

libraries/SerialFlash/examples/CopyFromSerial/CopyFromSerial.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
#define CSPIN 21
8383

8484
void setup(){
85-
Serial.begin(9600); //Teensy serial is always at full USB speed and buffered... the baud rate here is required but ignored
85+
Serial.begin(9600); // initialize Serial communication
86+
while(!Serial) ; // wait for serial port to connect.
8687

8788
pinMode(13, OUTPUT);
8889

0 commit comments

Comments
 (0)