2013-06-02 5 views
1

내 프로젝트는 Android로 제어되는 Arduino RC 자동차입니다. 그것을 위해 나는 Arduino Uno R3와 Arduino WiFi shield을 샀다. 문제는 wifiShield가 클라이언트를 경청하지 않고 데이터를받을 수 없다는 것입니다. 문제를 해결하는 방법을 모르며 장치간에 연결을 설정할 수 없습니다.Arduino Wifi Shield가 통신하지 않습니다.

아두 이노 코드 : 내 문제가 발생할 수 있습니다이며 어떻게 해결할 수 무엇

char ssid[] = "***";   
char pass[] = "***"; 
int status = WL_IDLE_STATUS; 

WiFiServer server(1991); 


boolean alreadyConnected = false; 

void setup() { 
    Serial.begin(9600); 
    Serial.println("Attempting to connect to WPA network..."); 
    Serial.print("SSID: "); 
    Serial.println(ssid); 

    status = WiFi.begin(ssid, pass); 
    if (status != WL_CONNECTED) { 
     Serial.println("Couldn't get a wifi connection"); 
     while(true); 
    } 
    else { 
     server.begin(); 
     server.status(); 
     Serial.print("Connected to wifi. My address:"); 
     IPAddress myAddress = WiFi.localIP(); 
     IPAddress inetAddress=WiFi.gatewayIP(); 
     Serial.println(myAddress); 

     Serial.println("Inet: "); 
     Serial.println(inetAddress); 
    } 
} 

void loop() { 

    WiFiClient client = server.available(); 

    if(client) { 
     if (!alreadyConnected) { 

      client.flush();  
      Serial.println("We have a new client"); 
      client.println("Hello, client!"); 
      alreadyConnected = true; 
     } 

     if (client.available() > 0) { 
      // read the bytes incoming from the client: 
      char thisChar = client.read(); 
      // echo the bytes back to the client: 
      server.write(thisChar); 
      // echo the bytes to the server as well: 
      Serial.write(thisChar); 
     } 
    } 
} 

?

+0

표시되는 출력은 무엇입니까? 어떤 상태 메시지가 인쇄됩니까? 왜 연결에 실패하면 무한 루프가 생깁니 까? – Bart

답변

3

이 동일한 문제가 발생했습니다. 1.0.5 대신 Arduino 1.0.3을 사용하고 있는지 확인하십시오. 그게 내게 해준 것입니다.

0

Arduino IDE 1.0.5 WiFi shield로 작업하면 작동하지 않을 것입니다. 1.0.3에서는 잘 작동합니다.

관련 문제