If I recall correctly, on an Uno R3, once a pin is declared as an input, writing to it only serves to turn on or off the pull-up, nothing more. And an input pin w/o the pull up could float high or low.
Though I suspect from your use of D3 that you may not be using an Uno R3, so even that may not be true. But even so, with the pin declared as an input, writing to it will not likely have the effect you appear to think it should.
Edit: if perchance you're using an ESP8266 board of some type, D3 is likely GPIO0, which is physically pulled up on the board.
Oh thanks for the infos bro. btw im using an esp8266 board but i've tried with D3,D4,D5,D6 and D7 and no one works. In OUTPUT mode its all fine, in INPUT starts problems
I moved your topic to an appropriate forum category @radiatesenga .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
The INPUT_PULLUP mode charges the pin socket.
Then the digitalWrite( pin, LOW ) turns the pullup off... but unless the socket is drained, each read samples 1 microamp as HIGH.
A jumper to ground would drain that pin in one cycle.
Hey OP! See how many reads it takes to drain the charge down to less than 1.1V using a loop. Should be 1000's, maybe a lot of 1000's but enough reads will get a LOW result!
I changed digitalRead to analogRead to see if it was floating current that made pin HIGH. The value of analogRead(pin) its always 1024 (the maximum ). If I connect the pin to GND it become LOW but it doesnt even comeback to HIGH with input...
Ignoring all the other responses - all valid - I'm wondering what you expect to achieve with this code? Do you just not understand about digital i/o?
I'd suggest you connect an LED and series resistor to pin D3 to show the effect (if any) of the digitalWrite when the pin is defined as an input.
Part of the issue is that the actual operation of the pinMode and DigitalWrite instructions is obfuscate by compilation. Using direct write to the I/O registers would be more transparent.
Ok so guys I resolved. It seems that the problem was my yk04 radio receiver, which pin D0 I used to close the circuit. This pin is always HIGH as it seems and not respond to trasmitter input (but that's another problem)... so the solution was simply to connect D3 pin to another pin of yk04. Yeah, it was a pretty stupid problem with my yk04. Thank u all btw for responding