on output pins

The docs state:

“Digital inputs return 0 or 1
As do digital outputs, and indeed all non-analog uses of the pin – i.e., will return the actual state of the pin even if it’s configured for output, SPI, UART, etc.”

is this still the case for digital outputs?

Doing a simple:
hardware.pin9.configure(DIGITAL_OUT_OD_PULLUP); hardware.pin9.write(1); server.log(;

logs 0, when I would obviously expect 1. Is this a bug, or am I missing something fundamental?

Well, the pin could be 0 there. You’re configuring an open-drain output, so writing ‘1’ to it simply turns off the driver and uses the internal (weak) pullup to set the state.

If you use DIGITAL_OUT, does it read as 1?

That makes sense I guess. If I use DIGITAL_OUT though, I still get 0.

Is there anything connected to that pin?

If I run this:


…I get 1 logged.

If you have something with a high load on the pin, say a relay without a transistor to drive it, then it will log as zero because even though the imp is trying to drive the pin high, it can’t put enough current in to bring the pin up to logic 1 level.

I think that must be it. I’ll just wrap the pin class and track the state myself, thanks for your help Hugo :slight_smile:

Generally though, if you are writing 1 and don’t get a 1 read back, you’ve overloaded the pin which is not a good thing…