Hello,
I try to make a push button work with a pullup resistor.
But I wonder if the wires are good.
My feeling is that there have to be a connection to the 5V port.
Project: Wokwi - Online ESP32, STM32, Arduino Simulator
Hello,
I try to make a push button work with a pullup resistor.
But I wonder if the wires are good.
My feeling is that there have to be a connection to the 5V port.
Project: Wokwi - Online ESP32, STM32, Arduino Simulator
It's wired correctly, and it works in the simulator. When the button is not pressed the serial terminal shows it is '1' = HIGH. When the button is pressed it shows '0' = LOW. If you wire it the same way with a real Arduino board it will work.
There already is such a connection, internally in the Arduino (the 5V supply is internally connected to the digital input pin via the internal pull-up resistor when you set the pin mode to INPUT_PULLUP).
oke
I got confused with this example : https://docs.arduino.cc/built-in-examples/digital/Button/
but if it's good I can work on my challenge
That example uses
pinMode(buttonPin, INPUT);
not
pinMode(buttonPin, INPUT_PULLUP);
oke, so when using pullup I do not have to use the 5V pin.
Learned another thing
As @Grb said: When you set the pinMode to INPUT_PULLUP, there is a resistor inside the Arduino chip that connects between the input pin and 5V.
If you set the pinMode to INPUT, then you would need to connect your own pull up resistor (typically 10k ohms) between the input pin and 5V.
Thanks all for the explanations.
Have still a lot to learn to really understand arduino
Even after the McWorther course ![]()
Do you have a copy of the Arduino Cookbook yet? It is a great learning tool.
nope.
I did this course : https://www.youtube.com/watch?v=fJWR7dBuc18&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP
and did all the challenges he made up.
But because I had a heart surgery I have to freshen up my knowlegde.
4 months not working on arduino and forget a lot
Yes. Books are where real education happens, Youtube is eye candy.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.