Skip to content

Instantly share code, notes, and snippets.

@paramaggarwal
Created September 17, 2012 14:05
Show Gist options
  • Save paramaggarwal/3737474 to your computer and use it in GitHub Desktop.
Save paramaggarwal/3737474 to your computer and use it in GitHub Desktop.
Arduino WiFly Shield Example Code
#include <SPI.h>
#include <WiFly.h>
// Wifi parameters
char passphrase[] = "passphrase";
char ssid[] = "ssid";
WiFlyClient client("google.com", 80);
void setup() {
Serial.begin(9600);
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment