Download Print this page

Arduino Yún Manual page 18

Advertisement

[Get Code]
Instantiate a server enabling the the Yun to listen for connected clients.
YunServer server;
In
, start serial communication for debugging purposes, and turn the built-in LED on pin
setup()
13 high while Bridge begins.
complete. Once Bridge starts up, turn the LED off.
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
[Get Code]
In the second part of
only coming from localhost. Connections made to Linino will be passed to the 32U4 processor
for parsing and controlling the pins. This happens on port 5555. Start the server with
.
server.begin()
server.listenOnLocalhost();
server.begin();
}
[Get Code]
In
, you'll create an instance of the YunClient for managing the connection. If the client
loop()
connects, process the requests in a custom function (described below) and close the connection
when finished.
Putting a delay at the end of
much work.
void loop() {
YunClient client = server.accept();
if (client) {
process(client);
client.stop();
}
delay(50);
}
[Get Code]
Create a function named
by creating a string to hold the incoming information. Parse the REST commands by their
functionality (digital, analog, and mode) and pass the information to the appropriately named
function.
Bridge.begin()
, tell the instance of YunServer to listen for incoming connections
setup()
will be helpful in keeping the processor from doing too
loop()
that accepts the YunClient as its argument. Read the command
process
is blocking, and should take about 2 seconds to

Advertisement

loading
Need help?

Need help?

Do you have a question about the Yún and is the answer not in the manual?

Questions and answers