source: arduino-1-6-7/trunk/fuentes/arduino-ide-amd64/libraries/Bridge/examples/HttpClient/HttpClient.ino @ 46

Last change on this file since 46 was 46, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 1.1 KB
Line 
1/*
2  Yún HTTP Client
3
4 This example for the Arduino Yún shows how create a basic
5 HTTP client that connects to the internet and downloads
6 content. In this case, you'll connect to the Arduino
7 website and download a version of the logo as ASCII text.
8
9 created by Tom igoe
10 May 2013
11
12 This example code is in the public domain.
13
14 http://www.arduino.cc/en/Tutorial/HttpClient
15
16 */
17
18#include <Bridge.h>
19#include <HttpClient.h>
20
21void setup() {
22  // Bridge takes about two seconds to start up
23  // it can be helpful to use the on-board LED
24  // as an indicator for when it has initialized
25  pinMode(13, OUTPUT);
26  digitalWrite(13, LOW);
27  Bridge.begin();
28  digitalWrite(13, HIGH);
29
30  Serial.begin(9600);
31
32  while (!Serial); // wait for a serial connection
33}
34
35void loop() {
36  // Initialize the client library
37  HttpClient client;
38
39  // Make a HTTP request:
40  client.get("http://www.arduino.cc/asciilogo.txt");
41
42  // if there are incoming bytes available
43  // from the server, read them and print them:
44  while (client.available()) {
45    char c = client.read();
46    Serial.print(c);
47  }
48  Serial.flush();
49
50  delay(5000);
51}
52
53
Note: See TracBrowser for help on using the repository browser.