Ethernet Begin blocks on board led and Digital Input ?

I have a strange problem. I want to create a client application that write a string on IP SOCKET every times 1 digital ping goes high (ex button pressed connected to pin 10)
I've realized a VB.NET web server that receives the string.
I've implemennted the Arduino web cliet following the example and if i write to my ip the string every tot seconds all works fine.
Then i added an event button handler on pin 10 and put the led off. When i press the button the button the led shoul go high and the string should be send on the socket.

The problem is that when i execute ethernet.begin () the let goes of and no data is received from digital pin.
Removing the istruction ethernet.begin the button and led works fine but obviously no data on net....

Some issue?

posting the code will give you way more responses and also a lot more valuable than this. Until then, we have no idea, what may be wrong.

ok, tomorrow morning i will post the code (i've it at office! ) thank's in advance

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

// il MAC Address lo posso inventare 
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10,1,101,191 };
byte server[] = { 10,1,101,175 }; // mio computer


// set pin numbers:
const int buttonPin = 8;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;     
int buttonStateOld = 0; // variable for reading the pushbutton status
int buffer = 0;

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
Client client(server, 8000);

void setup() {

  
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);  
    // start the Ethernet connection:
       
    
Ethernet.begin(mac, ip);
    // give the Ethernet shield a second to initialize:
  delay(1000);
 client.connect();

}

void loop()
{

 buttonState = digitalRead(buttonPin);


  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState != buttonStateOld)
 {
      if (buttonState == HIGH)
      {     
    // turn LED on:    
     digitalWrite(ledPin, HIGH);  
     buffer = buffer + 1 ;
      } 
  else 
    {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
    }
 
  if (buffer >= 3) 
    { String pippo;
      pippo = buffer;
    client.println("1111*"+ pippo + "#");
    buffer = 0;
    }
   

  }
   buttonStateOld=buttonState;
}

(ex button pressed connected to pin 10)

Would you be so kind as to point out where in that code you do anything with pin 10?

Pin 10 is used by the ethernet shield, as I'm sure you know.

oh yes you are right...in 1st version of my code i used pin 10 then i change it to pin 8 but still have same behaviour.
Maybe is the the usb power thant cannot give anought tension bot to the button both to ethernet shield?

Have you tried a simple sketch to see that the switch is wired correctly?

  if (buffer >= 3) 
    { String pippo;
      pippo = buffer;
    client.println("1111*"+ pippo + "#");
    buffer = 0;
    }

pippo is an instance of a String. buffer is an int. Have you tried writing the value in pippo to the serial port, and looking at the result on the Serial Monitor? I don't think that this code is doing what you think it is.

Have you verified that the + operator concatenates the literals and String object into a single item correctly?

Maybe is the the usb power thant cannot give anought tension bot to the button both to ethernet shield?

Too many mistakes in this sentence for me to parse it correctly. But, if you are asking if it is possible that the USB cable can not supply enough current for the switch and Ethernet shield at the same time, the answer is that the USB CAN supply enough current IF the switch is wired correctly.

But, if you are powering the Arduino/Ethernet shield from the USB cable, what is the purpose of the Ethernet shield? Why not just communicate directly with the PC?

thank's for your answer

  1. about pippo and buffer : this is not my problem, if i replace the input from button with input every 5 second, all works ok, the string is printed on my socket.
  2. my goal is to make ARDUINO communicate with a VB.NET program throught tcp/ip socket.
    Arduino count a digital input and every 3 signal, write a string on a a tcp/ip port. A second application in VB.NET read the data received on the port and write them on the database.

Actually my button (with no power) has 2 wires. The first 1 is plugged on pin 8, the second one is plugged on AREF. When i press the butto i close the circuit pin8-aref ans so on pin 8 i have my signal

It works correctly using the demo scretch digital-button.

The first 1 is plugged on pin 8, the second one is plugged on AREF. When i press the butto i close the circuit pin8-aref ans so on pin 8 i have my signal

It works correctly using the demo scretch digital-button.

Seeing as how AREF is an input, I find this difficult to believe. Still, when there is current flowing through the switch, the pin will read HIGH. When there is no current flowing, the pin may read HIGH or LOW, since you don't have a pull-down resistor to ensure a LOW value.

Aref is not a input....but if i connect my switch on pin 8 and aref, when switch is closed aref goes on pin 8 so pin 8 = HIGH. whn pin8 = high i turn on the internal led
All works.
But why if i execute ethernet.begin() method the switch and the led does't work?

Aref is not a input

Yes, it is. If all of the analog sensors being read have a maximum voltage of 4.0 volts, 4.0 volts can be supplied to the AREF pin, and 1023 from analogRead() will represent 4.0 volts, not 5.0 volts.

Why are you not using the +5V pin as the current source?

Do you have an external pull-down resistor? If not, you have a floating pin condition that is possibly being influenced by turning the ethernet shield on. You need a pull-up or pull-down resistor and the correct wiring for the switch.