source: rtos_arduino/trunk/arduino_lib/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.6 KB
Line 
1/*
2 Console Pixel
3
4 An example of using the Arduino board to receive data from the
5 Console on the Arduino Y炭n. In this case, the Arduino boards turns on an LED when
6 it receives the character 'H', and turns off the LED when it
7 receives the character 'L'.
8
9 To see the Console, pick your Y炭n's name and IP address in the Port menu
10 then open the Port Monitor. You can also see it by opening a terminal window
11 and typing
12 ssh root@ yourYunsName.local 'telnet localhost 6571'
13 then pressing enter. When prompted for the password, enter it.
14
15
16 The circuit:
17 * LED connected from digital pin 13 to ground
18
19 created 2006
20 by David A. Mellis
21 modified 25 Jun 2013
22 by Tom Igoe
23
24 This example code is in the public domain.
25
26 http://arduino.cc/en/Tutorial/ConsolePixel
27
28 */
29
30#include <Console.h>
31
32const int ledPin = 13; // the pin that the LED is attached to
33char incomingByte; // a variable to read incoming Console data into
34
35void setup() {
36 Bridge.begin(); // Initialize Bridge
37 Console.begin(); // Initialize Console
38
39 // Wait for the Console port to connect
40 while (!Console);
41
42 Console.println("type H or L to turn pin 13 on or off");
43
44 // initialize the LED pin as an output:
45 pinMode(ledPin, OUTPUT);
46}
47
48void loop() {
49 // see if there's incoming Console data:
50 if (Console.available() > 0) {
51 // read the oldest byte in the Console buffer:
52 incomingByte = Console.read();
53 Console.println(incomingByte);
54 // if it's a capital H (ASCII 72), turn on the LED:
55 if (incomingByte == 'H') {
56 digitalWrite(ledPin, HIGH);
57 }
58 // if it's an L (ASCII 76) turn off the LED:
59 if (incomingByte == 'L') {
60 digitalWrite(ledPin, LOW);
61 }
62 }
63}
64
Note: See TracBrowser for help on using the repository browser.