mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Merge branch 'ide-1.5.x-discovery' into dev-ide-1.5.x-discovery
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -26,3 +26,5 @@ test-bin
|
|||||||
.idea
|
.idea
|
||||||
|
|
||||||
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
|
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
|
||||||
|
|
||||||
|
hardware/arduino/avr/libraries/Bridge/examples/.DS_Store
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,18 +3,21 @@
|
|||||||
Running shell coommands using Process class.
|
Running shell coommands 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.
|
using an Arduino Yún. It runs the wifiCheck script on the linino side
|
||||||
|
of the Yun, then uses grep to get just the signal strength line.
|
||||||
|
Then it uses parseInt() to read the wifi signal strength as an integer,
|
||||||
|
and finally uses that number to fade an LED using analogWrite().
|
||||||
|
|
||||||
The circuit:
|
The circuit:
|
||||||
* Arduino Yun
|
* Arduino Yun with LED connected to pin 9
|
||||||
|
|
||||||
created 12 Jun 2013
|
created 12 Jun 2013
|
||||||
by Cristian Maglie
|
by Cristian Maglie
|
||||||
modified 21 June 2013
|
modified 25 June 2013
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
|
|
||||||
This example code is in the public domain.
|
This example code is in the public domain.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Process.h>
|
#include <Process.h>
|
||||||
@ -27,15 +30,23 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Process p;
|
Process p;
|
||||||
// This command line prints the name of the wireless network
|
// This command line runs the wifiCheck script, (lua /arduino/pretty...), then
|
||||||
// that the board is connected to, or the network which the board has created:
|
// sends the result to the grep command to look for a line containing the word
|
||||||
p.runShellCommand(F("lua /usr/lib/lua/pretty_wifi_info.lua | grep SSID"));
|
// "Signal:" the result is passed to this sketch:
|
||||||
|
p.runShellCommand("lua /arduino/pretty_wifi_info.lua | grep Signal");
|
||||||
|
|
||||||
// Read command output
|
// do nothing until the process finishes, so you get the whole output:
|
||||||
|
while(p.running());
|
||||||
|
|
||||||
|
// Read command output. runShellCommand() should have passed "Signal: xx&":
|
||||||
while (p.available()) {
|
while (p.available()) {
|
||||||
char c = p.read();
|
int result = p.parseInt(); // look for an integer
|
||||||
Serial.print(c);
|
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
|
||||||
|
Serial.println(result); // print the number as well
|
||||||
}
|
}
|
||||||
while (true); // do nothing more
|
delay(5000); // wait 5 seconds before you do it again
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ String dataString = "";
|
|||||||
void setup() {
|
void setup() {
|
||||||
// start serial port:
|
// start serial port:
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
Console.begin();
|
Serial.begin(9600);
|
||||||
|
|
||||||
while(!Console); // wait for Network Console to open
|
while(!Serial); // wait for Network Serial to open
|
||||||
Console.println("Xively client");
|
Serial.println("Xively client");
|
||||||
|
|
||||||
// Do a first update immediately
|
// Do a first update immediately
|
||||||
updateData();
|
updateData();
|
||||||
@ -83,7 +83,7 @@ void sendData() {
|
|||||||
// sendData function finishes the resources are immediately
|
// sendData function finishes the resources are immediately
|
||||||
// released. Declaring it global works too, BTW.
|
// released. Declaring it global works too, BTW.
|
||||||
Process xively;
|
Process xively;
|
||||||
Console.print("\n\nSending data... ");
|
Serial.print("\n\nSending data... ");
|
||||||
xively.begin("curl");
|
xively.begin("curl");
|
||||||
xively.addParameter("-k");
|
xively.addParameter("-k");
|
||||||
xively.addParameter("--request");
|
xively.addParameter("--request");
|
||||||
@ -94,13 +94,13 @@ void sendData() {
|
|||||||
xively.addParameter(apiString);
|
xively.addParameter(apiString);
|
||||||
xively.addParameter(url);
|
xively.addParameter(url);
|
||||||
xively.run();
|
xively.run();
|
||||||
Console.println("done!");
|
Serial.println("done!");
|
||||||
|
|
||||||
// If there's incoming data from the net connection,
|
// If there's incoming data from the net connection,
|
||||||
// send it out the Console:
|
// send it out the Serial:
|
||||||
while (xively.available()>0) {
|
while (xively.available()>0) {
|
||||||
char c = xively.read();
|
char c = xively.read();
|
||||||
Console.write(c);
|
Serial.write(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user