My wifi shield cant receive any data when i add Robot.begin(); in UDP example

I’m using the tute (https://arduinorobothelp.wordpress.com/) to help me connect the wifi shield to the arduino robot. and it worked (i use udp example and i can receive data from computer.

But my final goal is let computer to control the robot by using the wifi shield. So i’m using the udp example to send data.

But when i add Robot.begin(); in the code, then the wifi shield can’t receive any data from my computer.

I wondering is that because of i change the spi.dir?

very thanks.

#include <ArduinoRobot.h>

#include <WiFi.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
int a= 30,b=40,c=50,d=60;
char ssid[] = "default"; //  your network SSID (name) 
//char pass[] = "secretPassword";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

unsigned int localPort = 8080;      // local port to listen on

char packetBuffer[255]; //buffer to hold incoming packet
char  ReplyBuffer[] = "acknowledged";       // a string to send back

WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
//  Serial.begin(9600); 

  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:
    while(true);
  } 
  
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid);
  
    // wait 10 seconds for connection:
    delay(10000);
  } 
  Serial.println("Connected to wifi");
  printWifiStatus();
  
  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  Udp.begin(localPort);  
  //Robot.begin();
  
}

void loop() {
    
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if(packetSize)
  {   
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    Serial.print(remoteIp);
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    int len = Udp.read(packetBuffer,255);
    if (len >0) packetBuffer[len]=0;
    Serial.println("Contents:");
    Serial.println(packetBuffer);
    
    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
    if(packetBuffer[0]=='1'){
      a=100;
    }
       if(packetBuffer[0]=='3'){
      a=200;
    }
    
 
    
    Serial.println(a);
    Serial.println(b);
    Serial.println(c);
    Serial.println(d);
   // CommandMotors(a);
   }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

/*void CommandMotors(int LY){
  if(LY==100){
    Robot.motorsWrite(255, 255);  // move forward
      delay(4000);
      Robot.motorsStop();           // fast stop
      delay(1000);
  }
  if(LY==200){
       Robot.motorsWrite(-255, -255); // backward
      delay(3000);
      Robot.motorsWrite(0, 0);      // slow stop
      delay(1000);
  }
    if(LY==300){
    Robot.motorsWrite(-255, 255); // turn left
      delay(2000);
      Robot.motorsStop();           // fast stop
      delay(1000);
  }
}*/

You didn't answer my question.

what question?

LXin: what question?

Maybe it was on your cross post. It gets so confusing when you put the same thread in multiple places.

yes, i remove the LCD Screen. my problem is when i did't write robot.motorwrite(); wifi sheild can still reveice data from my computer. i can read the ip address of my computer and port.

But when i insert the robot.motorwrite(); then i think TKD3,TKD5,TKD5 is not sending data, all my data receive is 0, and cant read the ip address and port. may be the motor libary change the TKD pin back to the original pins?

very thanks