You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
5 years ago
|
/*
|
||
|
Yún HTTP Client Console version for Arduino Uno and Mega using Yún Shield
|
||
|
|
||
|
This example for the YunShield/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
|
||
|
May 2013
|
||
|
modified by Marco Brianza to use Console
|
||
|
|
||
|
This example code is in the public domain.
|
||
|
|
||
|
http://www.arduino.cc/en/Tutorial/HttpClient
|
||
|
|
||
|
*/
|
||
|
|
||
|
#include <Bridge.h>
|
||
|
#include <HttpClient.h>
|
||
|
#include <Console.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);
|
||
|
|
||
|
Console.begin();
|
||
|
|
||
|
while (!Console); // 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");
|
||
|
|
||
|
// if there are incoming bytes available
|
||
|
// from the server, read them and print them:
|
||
|
while (client.available()) {
|
||
|
char c = client.read();
|
||
|
Console.print(c);
|
||
|
}
|
||
|
Console.flush();
|
||
|
|
||
|
delay(5000);
|
||
|
}
|