problem with Ethernet Shield and Access Point

hi everybody! :slight_smile:
i'm creating a project for my school final exam.. :roll_eyes:
i would create a minirobot controlled by pc, on the robot there will be an ip camera..
my arduino and my ipcamera are connected to an access point, connecting my pc to the network i could control the robot with arduino and see the frontal video from the webcam. 8) :grin:

my problem is using the ethernet shield: my arduino is the server and my pc a client, in java on the pc i've just created a program who sends strings (byte to byte) to arduino and it receive it..
my first communication works: if the character received is 'a' i turn on a led, if the char is 's' i turn it off :slight_smile:
then i tried to create another program with many characters for the movements of my robot: 'w','a','s','d','x', and so on... it seems that digitalWrite(...,HIGH) doesn't works.. :frowning:
(all the motor control is already created and it works perfectly!)
i don't know if it's a logic problem.. someone can help me? :slight_smile:

these are the programs:
Led On Off Program (it works):

#include <SPI.h>
#include <Ethernet.h>
#include <stdlib.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  
byte ip[] = { 192, 168, 0, 177 };    
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup()
{
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  Ethernet.begin(mac, ip, gateway, subnet);

  server.begin();
}

void loop()
{
  char temp;
  EthernetClient client = server.available();
  if (client == true) {
    temp=client.read();
    
    Serial.println(temp);
    if(temp=='a')
      digitalWrite(2, HIGH);
    else if(temp=='s')
      digitalWrite(2, LOW);

    server.write(temp);
  }   
}

Motor Code (it doesn't work):

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  
byte ip[] = { 192, 168, 0, 177 };    
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server = EthernetServer(23);

int motor_left[] = {7, 8};   // pin 15, pin 10 (dell'integrato)
int motor_right[] = {5, 6};  // pin 2, pin 7 (dell'integrato)
int velocita = 9;            // PWM, pin 1,9 (dell'integrato)

void setup()
{
  Ethernet.begin(mac, ip, gateway, subnet);
  
  for(int i = 0; i < 2; i++){
    pinMode(motor_left[i], OUTPUT);
    pinMode(motor_right[i], OUTPUT);
  }
  pinMode(velocita, OUTPUT);
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  
  server.begin();
}

void loop()
{
  char temp;
  EthernetClient client = server.available();
  if (client == true) {
    temp=client.read();
    
    Serial.println(temp);
    
    if(temp=='s')
      motor_stop();
    else if(temp=='w')
      drive_forward();
    else if(temp=='x')
      drive_backward();
    else if(temp=='a')
      turn_left();
    else if(temp=='d')
      turn_right();
    else if(temp=='m')
      analogWrite(velocita, 255);
    else if(temp=='n')
      analogWrite(velocita, 140);

   server.write(temp);
  }
}

void motor_stop(){
  digitalWrite(motor_left[0], LOW);
  digitalWrite(motor_left[1], LOW);
  
  digitalWrite(motor_right[0], LOW);
  digitalWrite(motor_right[1], LOW);
}

void drive_forward(){
  digitalWrite(motor_left[0], HIGH);
  digitalWrite(motor_left[1], LOW);
  
  digitalWrite(motor_right[0], HIGH);
  digitalWrite(motor_right[1], LOW);
}

void drive_backward(){
  digitalWrite(motor_left[0], LOW);
  digitalWrite(motor_left[1], HIGH);
  
  digitalWrite(motor_right[0], LOW);
  digitalWrite(motor_right[1], HIGH);
}

void turn_left(){
  digitalWrite(motor_left[0], LOW);
  digitalWrite(motor_left[1], HIGH);
  
  digitalWrite(motor_right[0], HIGH);
  digitalWrite(motor_right[1], LOW);
}

void turn_right(){
  digitalWrite(motor_left[0], HIGH);
  digitalWrite(motor_left[1], LOW);
  
  digitalWrite(motor_right[0], LOW);
  digitalWrite(motor_right[1], HIGH);
}

anyone can help me? =(

What version of the Arduino IDE are you using? The IDE v1.0 would be best.

The Ethernet.begin() parameter format changed in v1.0. This is the new format:

Ethernet.begin(mac);
Ethernet.begin(mac,ip);
Ethernet.begin(mac,ip,dns);
Ethernet.begin(mac,ip,dns,gateway);
Ethernet.begin(mac,ip,dns,gateway,subnet);

Check the basic stuff first.

the problem was only that i hadn't set the analog out of motors :roll_eyes: :grin:
if someone is interested there's the video of the project completed! :slight_smile:
thank you for the help :wink: