Hi,
How to keep an input pin low?
pinMode(SWITCH, INPUT);
digitalWrite(SWITCH, LOW);
seems this set doesn't work.
Thanks
Adam
Hi,
How to keep an input pin low?
pinMode(SWITCH, INPUT);
digitalWrite(SWITCH, LOW);
seems this set doesn't work.
Thanks
Adam
Did you define "switch" as a pin number? You must else the poor processor has no idea which pin you are talking about and just keeps on looping
I'm definitely NOT trying to make fun of your question. We all have to learn so keep asking.
Can this sentence ‘How to keep an input pin low?’ itself be a question even without the code?
How do you know? What are you trying to do?
https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/
If the pin is configured as an
INPUT
,digitalWrite()
will enable (HIGH
) or disable (LOW
) the internal pullup on the input pin. It is recommended to set thepinMode()
toINPUT_PULLUP
to enable the internal pull-up resistor.
Connect it to ground. Use a resistor, if there is ever a chance that the pin will be declared an OUTPUT, and HIGH.
Thanks.
I print out the status of the 'SWITCH' pin, that is '1', even when set it be LOW.
I read that paragraph, and asking if there are any solution. maybe in hardware?
Given in reply #5
Inputs are just that; they are connected to a sensor, switch etc.
You use digitalRead( ) to see what logic level is on the pin.
Outputs can be set LOW or HIGH in which case the pin goes to 0V or 5V(3.3V).
A lot of questions…
What Arduino?
Pin 1 is part of the default serial port on a UNO and equivalents.
Seeing the whole code, the schematic, and a description of what you are hoping to do would be an immense help.
Thanks.
I'll do it.
There is also INPUT_PULLDOWN option, depends on hardware
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.