First make your code easy to read and meaningful, so you don't confuse yourself as to what you THINK you're doing.
You have a variable called 'Pin40' and you assign it the value 0.
You then do a a digitalWrite(40,HIGH), turning Pin 40 NOT 'Pin40' (actually Pin 0) on.
Then in your serial output you go back to trying to display the state on your variable 'Pin40', which is actually Pin 0, a pin you never actually set state for!
Probably clearer to call your variables something less confusing, like signalInPin and signalOutPin.
but the led wasn't collaborate it's remain On during 3 secons without In signal on Pin52.
AWOL, I'm using a protoboard just to try. But now I'm wired directly on the Arduino. Just one more, if I let the Arduino on the table ( wood table ) and only the led wired on pin 40 ( well, a litle pin post insert on pin 7 )and put my finger on the pin poste, the led blink on and off during a little time, non repetitive blinking.
Perhaps a shield is needed?, and Why you recomended wired in?
I'm use the IOREF for Inputs
The Arduino be supplied with a standard 223vAC to 12vDC 1.5A (18w) conversor
By the way, best thing to do when you are satisfied with the answers to a thread is edit your first post and add the word "SOLVED" at the front of the subject. Don't close the thread.....