I built the following simple circuit as an input to an ESP8266 microcontroller:

enter image description here

When I hold the switch closed, the input goes low. How do I modify this circuit to do the opposite? I want to press a switch to produce a high signal for the input to the microcontroller.

  • \$\begingroup\$ if you use INPUT_PULLUP, you only need the switch+ground+GPIO: no resistor or vcc \$\endgroup\$ – dandavis Jan 26 '18 at 5:57
  • \$\begingroup\$ @dandavis Thanks. Can you write that up as an answer? \$\endgroup\$ – Code-Guru Jan 26 '18 at 6:23
  • \$\begingroup\$ it doesn't answer the question asked as well as the given one, but glad to help. \$\endgroup\$ – dandavis Jan 26 '18 at 6:26
  • \$\begingroup\$ @dandavis It still answers the question that I didn't even know to ask. \$\endgroup\$ – Code-Guru Jan 26 '18 at 6:35

You can do this:


simulate this circuit – Schematic created using CircuitLab

| improve this answer | |
  • \$\begingroup\$ Of course! I need some resistance on the ground circuit to force the current from the source to go to the I/O connection. Thanks! \$\endgroup\$ – Code-Guru Jan 21 '18 at 18:09
  • 2
    \$\begingroup\$ It would be better to change the GPIO to pull-down as well. \$\endgroup\$ – Spehro Pefhany Jan 21 '18 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.