Since Uno and Mega has no Serial, replace Serial with Console at Bridge Sample IDE code

/*
  Yún HTTP Client
 This example for the Arduino Yún shows how create a basic
 HTTP client that connects to the internet and downloads
 content. In this case, you'll connect to the Arduino
 website and download a version of the logo as ASCII text.
 created by Tom igoe
 To see the Console, pick your Yún's name and IP address in the Port menu
 then open the Port Monitor. You can also see it by opening a terminal window
 and typing
 ssh root@ yourYunsName.local 'telnet localhost 6571'
 then pressing enter. When prompted for the password, enter it.
 May 2013
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/HttpClient
 */
#include <Console.h>
#include <HttpClient.h>
void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);
  //Serial.begin(9600);
  Console.begin();
  while (!Console) {
    ; // wait for Console port to connect.
  }
  // while (!Serial); // wait for a serial connection
}
void loop() {
  // Initialize the client library
  HttpClient client;
  // Make a HTTP request:
  //client.get("http://www.arduino.cc/asciilogo.txt");
  client.noCheckSSL();
  client.get("https://www.arduino.cc/asciilogo.txt");
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    //Serial.print(c);
    Console.print(c);
  }
  //Serial.flush();
  Console.flush();
  delay(5000);
}

Comments powered by CComment