Ethernet Shield Arduino - Turn on/off a led, a relay, etc

If I use the sketch of the example ArduinoEthernet in the setup:

pinMode(2, OUTPUT);

// pin control example (i.e. turning on/off a light, a relay, etc)
thing[“led”] << digitalPin(2);

the API works very well.

But if I use the example of the documentation:
thing[“led”] << [](pson& in){
digitalWrite(10, in ? HIGH : LOW);
};
the led turns on, but with a very low current.
How could I fix this?
I tested it at UNO and MEGA with the same resuts

Thanks!

I’m sorry. It seems I forgot to declare the pin as OUTPUT in the second case.

It works perfect with the following definition, and of course, you must declare the pin it as an output

pinMode(10, OUTPUT); thing["led"] << digitalPin(10)

It does the same thing that your code, but cleaner :wink: