Created
October 16, 2012 09:07
-
-
Save biskandar/3898195 to your computer and use it in GitHub Desktop.
Build Webserver with Arduino Leonardo and WiFi Shield 2012101612
This file contains hidden or 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
void setup() { | |
// initialize serial | |
Serial.begin( 9600 ) ; | |
while( !Serial ) ; // it only start the code when found serial pc terminal connected | |
// validate if the wifi shield plugged | |
if ( WiFi.status() == WL_NO_SHIELD ) { | |
Serial.println( "Wifi shield is not plugged yet" ) ; | |
while( true ) ; | |
} | |
// attempt to connect to an open network | |
Serial.println( "Attempting to connect to open network..." ) ; | |
status = WiFi.begin( ssid , pass ) ; | |
// if found not connected , stop here | |
if ( status != WL_CONNECTED ) { | |
Serial.println( "Couldn't get a wifi connection" ) ; | |
while ( true ) ; | |
} | |
// log it when found connected | |
Serial.println( "Connected to the network" ) ; | |
Serial.print( "SSID : " ) ; | |
Serial.println( WiFi.SSID() ) ; | |
Serial.print( "IP : " ) ; | |
Serial.println( WiFi.localIP() ) ; | |
// server start | |
server.begin() ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment