Skip to content

Commit e304d06

Browse files
committed
Added Massimo's Serial command line example
1 parent bf5ddb3 commit e304d06

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
/*
3+
Arduino Yun USB-to-Serial
4+
5+
Allows you to use the Yun's 32U4 processor as a
6+
serial terminal for the linino processor
7+
8+
Upload this to an Arduino Yun via serial (not WiFi)
9+
then open the serial monitor at 115200 to see the boot process
10+
of the linino processor. You can also use the serial monitor
11+
as a basic command line interface for the linino processor using
12+
this sketch.
13+
14+
The circuit:
15+
* Arduino Yun
16+
17+
created March 2013
18+
by Massimo Banzi
19+
20+
This example code is in the public domain.
21+
*/
22+
23+
long baud = 115200;
24+
25+
// Pin 13 has an LED connected on most Arduino boards.
26+
// give it a name:
27+
int led = 13;
28+
int ledState = HIGH; // whether the LED is high or low
29+
30+
31+
void setup() {
32+
Serial.begin(baud); // open serial connection to Linino
33+
Serial1.begin(baud); // open serial connection via USB-Serial
34+
Serial.println("Prova"); // Hello USB
35+
Serial1.println("Prova1"); // Hello Linino
36+
37+
// initialize the digital pin as an output.
38+
pinMode(led, OUTPUT);
39+
digitalWrite(led, ledState); // turn the LED on (HIGH is the voltage level)
40+
}
41+
42+
43+
void loop() {
44+
45+
// copy from virtual serial line to uart and vice versa
46+
if (Serial.available()) { // got anything from USB-Serial?
47+
char c = (char)Serial.read(); // read from USB-serial
48+
Serial1.write(c); // write to Linino
49+
ledState=!ledState; // invert LED state
50+
digitalWrite(led, ledState); // toggle the LED
51+
}
52+
if (Serial1.available()) { // got anything from Linino?
53+
char c = (char)Serial1.read(); // read from Linino
54+
Serial.write(c); // write to USB-serial
55+
}
56+
}
57+
58+
59+
60+
61+

0 commit comments

Comments
 (0)