Multiple buttons single pin

Hi i made this project on wokwi(mover no eliminar - Wokwi ESP32, STM32, Arduino Simulator) and i want all the buttons on the same pin but i am so confuse how to do it. i try to learn following some tutorials online adapting the same wiring schematic on the tutorials to my project and nothing any help please
thanks

Hello cuasitos

Post the current sketch and schematic to see how we can help.

  • You can use an analog input pin and a voltage divider.

Examples

Hi i am trying to connect multiple buttons single pin on wokwi for later transfer to a physical way.
My project is https://wokwi.com/projects/416105201673194497 but when i trying to load the project serial shows on cycle in Spanish because is my main language (valor analogico:0 and valor no reconocido) and when i press any button doesn't do nothing what i doing wrong.
Thanks

From wokwi:

warning

Wokwi only has a very basic analog circuit simulation. You won't be able to use resistors together with analog components (e.g. potentiometer or NTC temperature sensor). You can still use the resistors as external pull-up/pull-down resistors.

This is your problem. :wink:

What is wrong is you asking Wokwi to simulate something that is bad practice and cause lots of problems.

If you are short on GPIO pins, you can reduce the number of pins needed by arranging your switches in a matrix.

1 Like

This could be interesting I have no clue on how to simulate with Wok Wi! so I will assume you have an analog pin. free. This will allow you read several buttons but the limit is about 5.

This approach works by connecting multiple buttons through a resistor voltage divider network to generate unique analog voltage levels.

Circuit Explanation

  1. Resistor Voltage Divider:
  • Each button is connected in series with a unique resistor, creating distinct voltage levels when pressed. Only one is valid at any one time.
  • These resistors divide the voltage so the analog pin reads a different value for each button. You can use a higher value resistor but it will become more noise sensitive.
  1. Analog Pin:
  • The analog pin reads the voltage and maps it to a specific button based on its range. Be sure to connect the switches to the correct voltage, 5V will probably destroy your ESP processor.
  1. Limitations:
  • Practical use is generally limited to 5 buttons due to the need for distinct voltage levels and analog pin accuracy.

on that case maybe mi circuit is fine but wokwi can simulated?

Of course, in wokwi you can't simulate this type of analog circuit.