aboutsummaryrefslogtreecommitdiff
path: root/libraries/Bridge/examples/ConsolePixel
diff options
context:
space:
mode:
authorFederico Fissore <f.fissore@arduino.cc>2013-06-26 16:04:55 +0200
committerFederico Fissore <f.fissore@arduino.cc>2013-06-26 16:04:55 +0200
commitbf82b241f55a34543e94cea854d819d0a607988c (patch)
treefae9fa99088155d956b9c408d02b13f547007dea /libraries/Bridge/examples/ConsolePixel
parent4ba06563af4c74cb37aecf1b34136eec0772b5fb (diff)
parentf07c6f2a52af85a63e9e4ebb98d4673b4183287a (diff)
Merge branch 'ide-1.5.x-discovery' into dev-ide-1.5.x-discovery
Diffstat (limited to 'libraries/Bridge/examples/ConsolePixel')
-rw-r--r--libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino58
1 files changed, 58 insertions, 0 deletions
diff --git a/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
new file mode 100644
index 0000000..4201465
--- /dev/null
+++ b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino
@@ -0,0 +1,58 @@
+/*
+ Console Pixel
+
+ An example of using the Arduino board to receive data from the
+ Console on the Arduino Yun. In this case, the Arduino boards turns on an LED when
+ it receives the character 'H', and turns off the LED when it
+ receives the character 'L'.
+
+ To see the Console, pick your Yun's name and IP address in the Port menu
+ then open the Port Monitor. You can also see it by opening a terminal window
+ and typing
+ ssh root@ yourYunsName.local 'telnet localhost 6571'
+ then pressing enter. When prompted for the password, enter it.
+
+
+ The circuit:
+ * LED connected from digital pin 13 to ground
+
+ created 2006
+ by David A. Mellis
+ modified 25 Jun 2013
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ */
+#include <Console.h>
+
+const int ledPin = 13; // the pin that the LED is attached to
+char incomingByte; // a variable to read incoming Console data into
+
+void setup() {
+ // initialize Console communication:
+ Bridge.begin();
+ Console.begin();
+ while(!Console); // wait for the Console to open from the remote side
+ Console.println("type H or L to turn pin 13 on or off");
+ // initialize the LED pin as an output:
+ pinMode(ledPin, OUTPUT);
+}
+
+void loop() {
+ // see if there's incoming Console data:
+ if (Console.available() > 0) {
+ // read the oldest byte in the Console buffer:
+ incomingByte = Console.read();
+ Console.println(incomingByte);
+ // if it's a capital H (ASCII 72), turn on the LED:
+ if (incomingByte == 'H') {
+ digitalWrite(ledPin, HIGH);
+ }
+ // if it's an L (ASCII 76) turn off the LED:
+ if (incomingByte == 'L') {
+ digitalWrite(ledPin, LOW);
+ }
+ }
+}
+