Wifi shield connect to any open network

I am trying to make a sensor that will connect to any open network when turned on. I have the wifi shield and have been trying to use listnetworks() function like in the example (http://arduino.cc/en/Guide/ArduinoWiFiShield#toc5) but to no avail. Any ideas or sketch examples how to do this?

Thanks,
Kyle

No ideas? I am trying to connect to the open network on the University Campus but the names change throughout the campus.

but to no avail.

You posted a link to some code. Presumably, you loaded that code on the Arduino with official WiFi shield attached, and it produced some output. We have no idea what results you actually got.

I am trying to connect to the open network on the University Campus but the names change throughout the campus.

What kind of connection is needed? WEP or WPA? Do you have some lookup table with all the names and the corresponding passwords?

Or, are you expecting to connect with authentication just because you're special? The more details you provide, the less likely we are to assume that you are up to no good.

You can try this code, which is off the top of my head. I have not tested or even compiled it.

//try to connect to the first available open network
while(WiFi.status() != WL_CONNECTED) {
  byte numNets = WiFi.scanNetworks();
  for (byte thisNet = 0; thisNet < numNets; thisNet++) {
    //enumerate visible networks
    if (WiFi.encryptionType(thisNet) == 7) {
      //access point is open, try to connect
      WiFi.begin(Wifi.SSID(thisNet));
    }
    if (WiFi.status() == WL_CONNECTED) {
       //we are connected, break out the for loop
       break;
  }
}
[code]

[/code]