libraries / Bridge / examples / HttpClientConsole / HttpClientConsole.inoon commit Added link to project report (97a3ba0)
   1/*
   2  Yún HTTP Client Console version for Arduino Uno and Mega using Yún Shield
   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 modified by Marco Brianza to use Console
  12
  13 This example code is in the public domain.
  14
  15 http://www.arduino.cc/en/Tutorial/HttpClient
  16
  17 */
  18
  19#include <Bridge.h>
  20#include <HttpClient.h>
  21#include <Console.h>
  22
  23void setup() {
  24  // Bridge takes about two seconds to start up
  25  // it can be helpful to use the on-board LED
  26  // as an indicator for when it has initialized
  27  pinMode(13, OUTPUT);
  28  digitalWrite(13, LOW);
  29  Bridge.begin();
  30  digitalWrite(13, HIGH);
  31
  32  Console.begin();
  33
  34  while (!Console); // wait for a serial connection
  35}
  36
  37void loop() {
  38  // Initialize the client library
  39  HttpClient client;
  40
  41  // Make a HTTP request:
  42  client.get("http://www.arduino.cc/asciilogo.txt");
  43
  44  // if there are incoming bytes available
  45  // from the server, read them and print them:
  46  while (client.available()) {
  47    char c = client.read();
  48    Console.print(c);
  49  }
  50  Console.flush();
  51
  52  delay(5000);
  53}
  54
  55