Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DigitalIn Class Reference
A digital input, used for reading the state of a pin. More...
#include <DigitalIn.h>
Public Member Functions | |
DigitalIn (PinName pin) | |
Create a DigitalIn connected to the specified pin. | |
DigitalIn (PinName pin, PinMode mode) | |
Create a DigitalIn connected to the specified pin. | |
int | read () |
Read the input, represented as 0 or 1 (int) | |
void | mode (PinMode pull) |
Set the input pin mode. | |
int | is_connected () |
Return the output setting, represented as 0 or 1 (int) | |
operator int () | |
An operator shorthand for read() | |
DigitalIn (PinName pin) | |
Create a DigitalIn connected to the specified pin. | |
DigitalIn (PinName pin, PinMode mode) | |
Create a DigitalIn connected to the specified pin. | |
int | read () |
Read the input, represented as 0 or 1 (int) | |
void | mode (PinMode pull) |
Set the input pin mode. | |
int | is_connected () |
Return the output setting, represented as 0 or 1 (int) | |
operator int () | |
An operator shorthand for read() |
Detailed Description
A digital input, used for reading the state of a pin.
Synchronization level: Interrupt safe
Example:
// Flash an LED while a DigitalIn is true #include "mbed.h" DigitalIn enable(p5); DigitalOut led(LED1); int main() { while(1) { if(enable) { led = !led; } wait(0.25); } }
Definition at line 49 of file mbed-dev/api/DigitalIn.h.
Constructor & Destructor Documentation
DigitalIn | ( | PinName | pin ) |
Create a DigitalIn connected to the specified pin.
- Parameters:
-
pin DigitalIn pin to connect to
Definition at line 56 of file mbed-dev/api/DigitalIn.h.
DigitalIn | ( | PinName | pin, |
PinMode | mode | ||
) |
Create a DigitalIn connected to the specified pin.
- Parameters:
-
pin DigitalIn pin to connect to mode the initial mode of the pin
Definition at line 66 of file mbed-dev/api/DigitalIn.h.
DigitalIn | ( | PinName | pin ) |
Create a DigitalIn connected to the specified pin.
- Parameters:
-
pin DigitalIn pin to connect to
Definition at line 56 of file usb_cdc/mbed-dev/api/DigitalIn.h.
DigitalIn | ( | PinName | pin, |
PinMode | mode | ||
) |
Create a DigitalIn connected to the specified pin.
- Parameters:
-
pin DigitalIn pin to connect to mode the initial mode of the pin
Definition at line 66 of file usb_cdc/mbed-dev/api/DigitalIn.h.
Member Function Documentation
int is_connected | ( | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- Non zero value if pin is connected to uc GPIO 0 if gpio object was initialized with NC
Definition at line 97 of file mbed-dev/api/DigitalIn.h.
int is_connected | ( | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- Non zero value if pin is connected to uc GPIO 0 if gpio object was initialized with NC
Definition at line 97 of file usb_cdc/mbed-dev/api/DigitalIn.h.
void mode | ( | PinMode | pull ) |
Set the input pin mode.
- Parameters:
-
mode PullUp, PullDown, PullNone, OpenDrain
Definition at line 85 of file mbed-dev/api/DigitalIn.h.
void mode | ( | PinMode | pull ) |
Set the input pin mode.
- Parameters:
-
mode PullUp, PullDown, PullNone, OpenDrain
Definition at line 85 of file usb_cdc/mbed-dev/api/DigitalIn.h.
operator int | ( | ) |
An operator shorthand for read()
Definition at line 104 of file mbed-dev/api/DigitalIn.h.
operator int | ( | ) |
An operator shorthand for read()
Definition at line 104 of file usb_cdc/mbed-dev/api/DigitalIn.h.
int read | ( | ) |
Read the input, represented as 0 or 1 (int)
- Returns:
- An integer representing the state of the input pin, 0 for logical 0, 1 for logical 1
Definition at line 76 of file mbed-dev/api/DigitalIn.h.
int read | ( | void | ) |
Read the input, represented as 0 or 1 (int)
- Returns:
- An integer representing the state of the input pin, 0 for logical 0, 1 for logical 1
Definition at line 76 of file usb_cdc/mbed-dev/api/DigitalIn.h.
Generated on Tue Jul 12 2022 22:19:22 by
