diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-06-05 14:51:15 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-06-05 14:51:15 +0200 |
commit | 48a4f76e4271567a7c7649c507668e23345190c3 (patch) | |
tree | baa90058912d9140b916e2451d8afacf2bb0b49d /libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino | |
parent | 4306561e25f2a57c5f86f6cde22a1d306101487f (diff) |
Updated some Bridge examples
Diffstat (limited to 'libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino')
-rw-r--r-- | libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino index dea2ef5..aa152e1 100644 --- a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino +++ b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino @@ -1,9 +1,8 @@ - /* Arduino Yun USB-to-Serial Allows you to use the Yun's 32U4 processor as a - serial terminal for the linino processor + serial terminal for the linino processor. Upload this to an Arduino Yun via serial (not WiFi) then open the serial monitor at 115200 to see the boot process @@ -11,28 +10,31 @@ as a basic command line interface for the linino processor using this sketch. + From the serial monitor the following commands can be issued: + + '~' followed by '0' -> Set the UART speed to 57600 baud + '~' followed by '1' -> Set the UART speed to 115200 baud + The circuit: * Arduino Yun created March 2013 by Massimo Banzi + modified by Cristian Maglie This example code is in the public domain. */ -long baud = 115200; +long lininoBaud = 57600; // Pin 13 has an LED connected on most Arduino boards. -// give it a name: int led = 13; int ledState = HIGH; // whether the LED is high or low void setup() { - Serial.begin(baud); // open serial connection to Linino - Serial1.begin(baud); // open serial connection via USB-Serial - Serial.println("Prova"); // Hello USB - Serial1.println("Prova1"); // Hello Linino + Serial.begin(115200); // open serial connection via USB-Serial + Serial1.begin(lininoBaud); // open serial connection to Linino // initialize the digital pin as an output. pinMode(led, OUTPUT); @@ -40,12 +42,31 @@ void setup() { } -void loop() { +boolean commandMode = false; +void loop() { // copy from virtual serial line to uart and vice versa if (Serial.available()) { // got anything from USB-Serial? char c = (char)Serial.read(); // read from USB-serial - Serial1.write(c); // write to Linino + if (commandMode == false) { // if we aren't in command mode... + if (c == '~') { // Tilde '~' key pressed? + commandMode = true; // enter in command mode + } else { + Serial1.write(c); // otherwise write char to Linino + } + } else { // if we are in command mode... + if (c == '0') { // '0' key pressed? + Serial1.begin(57600); // set speed to 57600 + Serial.println("Speed set to 57600"); + } else if (c == '1') { // '1' key pressed? + Serial1.begin(115200); // set speed to 115200 + Serial.println("Speed set to 115200"); + } else { // any other key pressed? + Serial1.write('~'); // write '~' to Linino + Serial1.write(c); // write char to Linino + } + commandMode = false; // in all cases exit from command mode + } ledState=!ledState; // invert LED state digitalWrite(led, ledState); // toggle the LED } |