DigitalIn¶
-
class
DigitalIn¶ Public Functions
-
DigitalIn(PinName pin, PullType pull = PullType::PullNone)¶ Configures GPIO pin for digital in.
- Parameters
pin: Pin def external to boardpull: Pin pull type
-
void
DeInit()¶ Deinitializes the GPIO pin as a digital input.
-
bool
Read()¶ Read current value of pin.
- Return
true (high) or false (low)
-
operator bool()¶ Boolean operator overload to return current pin value.
- Return
true
- Return
false
-
void
setPull(PullType pull)¶ Function to change pull type after object initialization.
- Parameters
pull: Pin pull type
-
Example Usage:¶
DigitalIn myInput(PIN_E5, PullNone);
if (myInput.Read())
{
print("myInput is high!");
}
else
{
print("myInput is low!");
}
Note
Make sure that you have initialized the GPIO peripheral clock for your GPIO port before initializing the pin as an input.