modifide comments in Yun examples ShellCommands.ino ConsolePixel.ino

This commit is contained in:
Fede85 2013-07-02 21:23:59 +02:00
parent 13c664ed48
commit a1f48d22ac
2 changed files with 20 additions and 14 deletions

View File

@ -6,7 +6,7 @@
it receives the character 'H', and turns off the LED when it it receives the character 'H', and turns off the LED when it
receives the character 'L'. receives the character 'L'.
To see the Console, pick your Yun's name and IP address in the Port menu To see the Console, pick your Yún's name and IP address in the Port menu
then open the Port Monitor. You can also see it by opening a terminal window then open the Port Monitor. You can also see it by opening a terminal window
and typing and typing
ssh root@ yourYunsName.local 'telnet localhost 6571' ssh root@ yourYunsName.local 'telnet localhost 6571'
@ -24,17 +24,21 @@
This example code is in the public domain. This example code is in the public domain.
*/ */
#include <Console.h> #include <Console.h>
const int ledPin = 13; // the pin that the LED is attached to const int ledPin = 13; // the pin that the LED is attached to
char incomingByte; // a variable to read incoming Console data into char incomingByte; // a variable to read incoming Console data into
void setup() { void setup() {
// initialize Console communication: Bridge.begin(); // Initialize Bridge
Bridge.begin(); Console.begin(); // Initialize Console
Console.begin();
while(!Console); // wait for the Console to open from the remote side // Wait for the Console port to connect
while(!Console);
Console.println("type H or L to turn pin 13 on or off"); Console.println("type H or L to turn pin 13 on or off");
// initialize the LED pin as an output: // initialize the LED pin as an output:
pinMode(ledPin, OUTPUT); pinMode(ledPin, OUTPUT);
} }

View File

@ -1,6 +1,6 @@
/* /*
Running shell coommands using Process class. Running shell commands using Process class.
This sketch demonstrate how to run linux shell commands This sketch demonstrate how to run linux shell commands
using an Arduino Yún. It runs the wifiCheck script on the linino side using an Arduino Yún. It runs the wifiCheck script on the linino side
@ -23,9 +23,11 @@
#include <Process.h> #include <Process.h>
void setup() { void setup() {
// initialize the Bridge and Serial connections: Bridge.begin(); // Initialize the Bridge
Bridge.begin(); Serial.begin(9600); // Initialize the Serial
Serial.begin(9600);
// Wait until a Serial Monitor is connected.
while(!Serial);
} }
void loop() { void loop() {
@ -40,12 +42,12 @@ void loop() {
// Read command output. runShellCommand() should have passed "Signal: xx&": // Read command output. runShellCommand() should have passed "Signal: xx&":
while (p.available()) { while (p.available()) {
int result = p.parseInt(); // look for an integer int result = p.parseInt(); // look for an integer
int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255 int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255
analogWrite(9, signal); // set the brightness of LED on pin 9 analogWrite(9, signal); // set the brightness of LED on pin 9
Serial.println(result); // print the number as well Serial.println(result); // print the number as well
} }
delay(5000); // wait 5 seconds before you do it again delay(5000); // wait 5 seconds before you do it again
} }