Changes the configuration of this pin.
If input is true, the pin is configured as an input.
If output is true, the pin is configured as an output. If open-drain is set, then the pin value is set to 1 (not pulling to ground). Otherwise the pin outputs 0.
It is safe to use a pin as input and output at the same time, but typically this requires the open-drain flag.
If a pin is used as input and output without open-drain, then the pin can only read the value that was set with set. It can/should not read a value that was set by the outside. In fact, doing so could damage the microcontroller, as the external device would need to short circuit the pin. If a pin is configured to be an input, it can have a pull-up or pull-down.
If the pin is configured as output, the value can be set with the value parameter. The new value might be written *before* the configuration is changed. If the pin is configured from push-pull to open-drain care must be taken that the new value is not 1, thus potentially short-circuiting the pin if another device is pulling the line low. When switching from push-pull to open-drain it is thus recommended to go through a short period of high-impedance (input) mode to avoid this issue.
If open-drain is set, then the pin can only pull the pin to the ground. Together, with a pull-up resistor this still allows the pin to emit both 0 and 1. In this configuration, connected devices can also safely pull the pin to ground without damaging the microcontroller. This configuration is typically used in communications that only use one data bus for input and output, such as the DHT11/DHT22, the i2c bus, and the one-wire bus. Note, that the corresponding libraries (like the i2c library) already take care of setting this configuration for you.
Note that it is not safe to ground an open-drain pin and to connect it externally to VCC.
Also note, that only one entity on an open-drain bus needs to pull the bus high. As such, it can be useful to set open-drain without pull-up.