Skip to content

Commit b4a5f4f

Browse files
Merge pull request firmata#203 from firmata/leonardo-serial-ready
wait for ATMega32u4 Serial port to connect. add not about using other…
2 parents 20966a6 + 2bc2893 commit b4a5f4f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

examples/StandardFirmata/StandardFirmata.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
See file LICENSE.txt for further informations on licensing terms.
2222
23-
Last updated by Jeff Hoefs: May 17, 2015
23+
Last updated by Jeff Hoefs: May 30, 2015
2424
*/
2525

2626
#include <Servo.h>
@@ -692,7 +692,16 @@ void setup()
692692
Firmata.attach(START_SYSEX, sysexCallback);
693693
Firmata.attach(SYSTEM_RESET, systemResetCallback);
694694

695+
// to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega,
696+
// Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this:
697+
// Serial1.begin(57600);
698+
// Firmata.begin(Serial1);
699+
// then comment out or remove lines 701 - 704 below
700+
695701
Firmata.begin(57600);
702+
while (!Serial) {
703+
; // wait for serial port to connect. Only needed for ATmega32u4-based boards (Leonardo, etc).
704+
}
696705
systemResetCallback(); // reset to default config
697706
}
698707

0 commit comments

Comments
 (0)