I cannot make the serial event demo work on the Yun. The they both work independently, but this won't produce any output:
/*
Serial Event example
*/
#include <Console.h>
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup() {
Bridge.begin();
Console.begin();
while (!Console){
; // wait for Console port to connect.
}
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
}
void loop() {
// print the string when a newline arrives:
if (stringComplete) {
Console.println(inputString);
// clear the string:
inputString = "";
stringComplete = false;
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}
I have a GPS shield jumpered to pins 1 and 0. It works fine on an Uno on pins 3,4. I have tried Serial1 and swapped the pins.
Best regards,
Mike