![Arduino Yun Скачать руководство пользователя страница 17](http://html1.mh-extra.com/html/arduino/yun/yun_manual_2966336017.webp)
// Do nothing here.
}
void runCurl() {
// Launch "curl" command and get Arduino ascii art logo from the network
// curl is command line program for transferring data using different internet protocols
Process p; // Create a process and call it "p"
p.begin("curl"); // Process that launch the "curl" command
p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
p.run(); // Run the process and wait for its termination
// Print arduino logo over the Serial
// A process output can be read with the stream methods
while (p.available()>0) {
char c = p.read();
Serial.print(c);
}
// Ensure the last bit of data is sent.
Serial.flush();
}
[Get Code]
Using Bridge to pass information between processors
Bridge allows you to pass information between the two processors using a key/value pairing.
This example shows how to use the Bridge library to access the digital and analog pins on the
board through REST calls. It demonstrates how you can create your own API when using REST
style calls through the browser.
When running this example, make sure your computer is on the same network as the Yun.
When you have have programmed the board, you can request the value on a pin, write a value to
a pin, and configure a pin as an input or output.
When the REST password is turned off, you can use a browser with the following URL structure
:
http://myArduinoYun.local/arduino/digital/13
: calls digitalRead(13);
http://myArduinoYun.local/arduino/digital/13/1
: calls digitalWrite(13,1);
http://myArduinoYun.local/arduino/analog/9/123
: analogWrite(9,123);
http://myArduinoYun.local/arduino/analog/2
: analogRead(2);
http://myArduinoYun.local/arduino/mode/13/input
: pinMode(13, INPUT);
http://myArduinoYun.local/arduino/mode/13/output
: pinMode(13, OUTPUT);
You can use the curl command from the command line instead of a browser if you prefer.
You need to include the Bridge, YunServer, and YunClient libraries :
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>