1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-04 15:24:12 +01:00
Arduino/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino

65 lines
1.6 KiB
Arduino
Raw Normal View History

2013-06-25 19:57:19 +02:00
/*
Console Pixel
An example of using the Arduino board to receive data from the
2014-05-30 12:17:09 +02:00
Console on the Arduino Yún. In this case, the Arduino boards turns on an LED when
2013-06-25 19:57:19 +02:00
it receives the character 'H', and turns off the LED when it
receives the character 'L'.
To see the Console, pick your Yún's name and IP address in the Port menu
2013-06-25 19:57:19 +02:00
then open the Port Monitor. You can also see it by opening a terminal window
and typing
2013-06-25 19:57:19 +02:00
ssh root@ yourYunsName.local 'telnet localhost 6571'
then pressing enter. When prompted for the password, enter it.
2013-06-25 19:57:19 +02:00
The circuit:
* LED connected from digital pin 13 to ground
2013-06-25 19:57:19 +02:00
created 2006
by David A. Mellis
modified 25 Jun 2013
by Tom Igoe
2013-06-25 19:57:19 +02:00
This example code is in the public domain.
2013-09-09 20:56:15 +02:00
http://arduino.cc/en/Tutorial/ConsolePixel
2013-06-25 19:57:19 +02:00
*/
2013-06-25 19:57:19 +02:00
#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() {
Bridge.begin(); // Initialize Bridge
Console.begin(); // Initialize Console
// Wait for the Console port to connect
while (!Console);
2013-06-25 19:57:19 +02:00
Console.println("type H or L to turn pin 13 on or off");
2013-06-25 19:57:19 +02:00
// 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);
}
2013-06-25 19:57:19 +02:00
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}