Good afternoon forum. Had a question on the Nano regarding inputs. First time using this board and have had some experience on the Uno. I'm trying out some of the example sketches that Arduino provides and have had issues getting them to work, specifically with sketches that require inputs. I tried for the example the Debounce code example and pushing a button wouldn't change the LED. I found that the input voltage level was 3.3V with nothing connected to the pin, which explains why it wasn't working as the pin was already high and wasn't toggling back to low. Is this just a Nano thing? I wasn't expecting the inputs to pull high. I did regular INPUT too and not INPUT_PULLUP. However it doesn't matter which one I use, as an input there is always a 3.3V voltage on the line. Just want to make sure I understand how inputs work on the Nano as I did not see this on the Uno. Thank you!
placebo0311:
I did regular INPUT
In INPUT mode, the pin is floating and can be in any state. You need to to have a circuit that will always put the pin in a known state. This is done using a pull-up or pull-down resistor. Perhaps your pin happened to be floating in the state you expected on the Uno, but that is in no way guaranteed.
This is why the Debounce tutorial shows a resistor in the wiring diagram:
https://www.arduino.cc/en/Tutorial/Debounce
If you use that circuit, it should work as you expect.
Appreciate the feedback. I did miss this resistor. I will create the circuit as described and try again. Thank you!
You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per
pert:
In INPUT mode, the pin is floating and can be in any state. You need to to have a circuit that will always put the pin in a known state. This is done using a pull-up or pull-down resistor. Perhaps your pin happened to be floating in the state you expected on the Uno, but that is in no way guaranteed.This is why the Debounce tutorial shows a resistor in the wiring diagram:
https://www.arduino.cc/en/Tutorial/Debounce
If you use that circuit, it should work as you expect.
I had the same problem, until I went through and modified the 7 files listed here;
This seemed to fix things for me, and I had assumed that the Nano 33 BLE (at least) had a problem with the original arduino libraries. Am I missing something?
There's another thread with the same issue;
Thanks for sharing your findings and references @t6jay! I was aware of the issue related to pins in OUTPUT mode that is fixed by Restructure core bindings by facchinm · Pull Request #31 · arduino/ArduinoCore-nRF528x-mbedos · GitHub, but I didn't know it was also related to pin state in INPUT mode.
t6jay:
This seemed to fix things for me, and I had assumed that the Nano 33 BLE (at least) had a problem with the original arduino libraries. Am I missing something?
It depends on what you mean by "libraries". Although the standard Arduino core API can be used to program the Nano 33 BLE, as with all official Arduino boards (and most 3rd party boards as well), the way the code for that API is implemented is very different for the Nano 33 BLE than for any of the previous Arduino boards. For the Nano 33 BLE, Arduino chose to use Mbed OS with a wrapper to translate it to the standard Arduino API. This approach currently results in some of the Arduino API functions not working as they do on other boards. There is ongoing work to improve the situation, as you see in Restructure core bindings by facchinm · Pull Request #31 · arduino/ArduinoCore-nRF528x-mbedos · GitHub. This code is in what is called the "core":
ArduinoCore-nRF528x-mbedos/cores/arduino at master · arduino/ArduinoCore-nRF528x-mbedos · GitHub
Although the core is not what most people mean when they say "Arduino library", I do consider it to be a library in that it serves the same purpose of allowing code to be easily shared between multiple Arduino programs.