Hello, I’m rather new to Arduino and XOD so please excuse me if this is answered better elsewhere; I did some searching and I didn’t find a definitive answer.
I have heard that Arduino boards (I’m specifically working with the nano r3) have internal pull up resistors on digital inputs. Does XOD have any way of implementing this feature?
It does not currently, but I don’t think it would be difficult to add another input pin to the digital-read & button nodes to indicate what value should be written to the input port to set the resistor. I don’t know if it is worth adding state so write only happens on 1st call or when port # or pull-up value changes…
If you make a copy of digital-read, I think you just need to add a “PULL” pin and after:
::pinMode(port, INPUT);
Add the line:
::digitalWrite(port, getValue<input_PULL>(ctx)));
I’m not sure if you can use input-boolean for the PULL pin without doing explicit casting. If that doesn’t work, you can use input-number, but input should only be 0 or 1.
Haha thank you, I really was just looking to turn them on, I wasn’t worried about their value (I just didn’t want to solder in a bunch of resistors for my many buttons).
I think
::digitalWrite(pin, HIGH);
Should get me there, is there any reason this wouldn’t work in the digital-read node?
It will, but if you modify the default nodes, it creates a copy of them in your workspace and they won’t get updated when you update XOD, and it will likely cause problems eventually. If you create your own copy, the core copy will still get updated when you update XOD.
Note: the awgrover code suggested by dox will NOT change the pullup setting if the PULLUP pin changes. It will work fine if PULLUP is hard-coded (which probably covers 99+% of cases), but you cannot use that node to change the PULLUP setting after initialization (unless you also change the PORT).
The issue with pull-up resistors arises from time to time. I think we should improve the standard library a bit to make them supported out of the box. So, I added #1439 to our backlog.