libraries / Bridge / examples / HttpClient / HttpClient.inoon commit Added link to project report (97a3ba0)
   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  SerialUSB.begin(9600);
  31
  32  while (!SerialUSB); // 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    SerialUSB.print(c);
  47  }
  48  SerialUSB.flush();
  49
  50  delay(5000);
  51}
  52
  53