Created
September 17, 2012 14:05
-
-
Save paramaggarwal/3737474 to your computer and use it in GitHub Desktop.
Arduino WiFly Shield Example Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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