dsyleixa123
Posts: 1025
Joined: Mon Jun 11, 2018 11:22 am

wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Sun Aug 02, 2020 5:53 pm

hello,
using wiringPi, what happens if I incidentally digitalWrite() to a pin which is defined as pinMode(pin,INPUT)?

User avatar
rpdom
Posts: 17705
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Sun Aug 02, 2020 5:55 pm

Try it and see? It won't break anything.

I haven't tried it, but I would expect it to either throw an error, or set the output state, which won't have any effect on an input pin.
Unreadable squiggle

dsyleixa123
Posts: 1025
Joined: Mon Jun 11, 2018 11:22 am

Re: wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Sun Aug 02, 2020 5:58 pm

I actually did it already but didn't observe anything obvious - not sure if I perhaps might damage sth though

User avatar
DougieLawson
Posts: 40167
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Sun Aug 02, 2020 9:32 pm

Have you noticed that wiringPi is deprecated. You should NOT use deprecated code for new development as it may break in future and will NOT work on any future RPis.
http://wiringpi.com/wiringpi-deprecated/
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

fbe
Posts: 648
Joined: Thu Aug 17, 2017 9:08 pm

Re: wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Sun Aug 02, 2020 9:49 pm

digitalWrite writes to the GPSET*/GPCLR* registers.
If the GPIO pin is being used as an input (by default) then the value in the SETn field is ignored. However, if the pin is subsequently defined as an output then the bit will be set according to the last set/clear operation.
https://www.raspberrypi.org/documentati ... 11_1p0.pdf

Please stop using wiringPi!

dsyleixa123
Posts: 1025
Joined: Mon Jun 11, 2018 11:22 am

Re: wiringPi: incidentally digitalWrite() to a pin which is defined as input?

Mon Aug 03, 2020 7:24 am

DougieLawson wrote:
Sun Aug 02, 2020 9:32 pm
Have you noticed that wiringPi is deprecated. You should NOT use deprecated code for new development as it may break in future and will NOT work on any future RPis.
As long as wiringPi will not be further maintained again, I'll NEVER EVER buy new Raspis again and also won't use Buster etc, and so just work on my old Pis using Stretch. All works like a charm with wiringPi and all my console and my qt5 creator programs and many more, so no need to change all that.

@fbe:
thanks for clarification, of course I'll stay with wiringPi though
- pigpio is far too hard to understand, provides far too few example source codes, and it's not compatible to my program codes using the wiringPi API libs, and Arduino-like API syntax is indispensable! 8-)

Return to “C/C++”