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.
DigitalOut Class Reference
A digital output, used for setting the state of a pin. More...
#include <DigitalOut.h>
Public Member Functions | |
DigitalOut (PinName pin) | |
Create a DigitalOut connected to the specified pin. | |
DigitalOut (PinName pin, int value) | |
Create a DigitalOut connected to the specified pin. | |
void | write (int value) |
Set the output, specified as 0 or 1 (int) | |
int | read () |
Return the output setting, represented as 0 or 1 (int) | |
int | is_connected () |
Return the output setting, represented as 0 or 1 (int) | |
DigitalOut & | operator= (int value) |
A shorthand for write() | |
operator int () | |
A shorthand for read() | |
DigitalOut (PinName pin) | |
Create a DigitalOut connected to the specified pin. | |
DigitalOut (PinName pin, int value) | |
Create a DigitalOut connected to the specified pin. | |
void | write (int value) |
Set the output, specified as 0 or 1 (int) | |
int | read () |
Return the output setting, represented as 0 or 1 (int) | |
int | is_connected () |
Return the output setting, represented as 0 or 1 (int) | |
DigitalOut & | operator= (int value) |
A shorthand for write() | |
operator int () | |
A shorthand for read() |
Detailed Description
A digital output, used for setting the state of a pin.
Synchronization level: Interrupt safe
Example:
// Toggle a LED #include "mbed.h" DigitalOut led(LED1); int main() { while(1) { led = !led; wait(0.2); } }
Definition at line 44 of file mbed-dev/api/DigitalOut.h.
Constructor & Destructor Documentation
DigitalOut | ( | PinName | pin ) |
Create a DigitalOut connected to the specified pin.
- Parameters:
-
pin DigitalOut pin to connect to
Definition at line 51 of file mbed-dev/api/DigitalOut.h.
DigitalOut | ( | PinName | pin, |
int | value | ||
) |
Create a DigitalOut connected to the specified pin.
- Parameters:
-
pin DigitalOut pin to connect to value the initial pin value
Definition at line 61 of file mbed-dev/api/DigitalOut.h.
DigitalOut | ( | PinName | pin ) |
Create a DigitalOut connected to the specified pin.
- Parameters:
-
pin DigitalOut pin to connect to
Definition at line 51 of file usb_cdc/mbed-dev/api/DigitalOut.h.
DigitalOut | ( | PinName | pin, |
int | value | ||
) |
Create a DigitalOut connected to the specified pin.
- Parameters:
-
pin DigitalOut pin to connect to value the initial pin value
Definition at line 61 of file usb_cdc/mbed-dev/api/DigitalOut.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 93 of file mbed-dev/api/DigitalOut.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 93 of file usb_cdc/mbed-dev/api/DigitalOut.h.
operator int | ( | ) |
A shorthand for read()
Definition at line 115 of file mbed-dev/api/DigitalOut.h.
operator int | ( | ) |
A shorthand for read()
Definition at line 115 of file usb_cdc/mbed-dev/api/DigitalOut.h.
DigitalOut& operator= | ( | int | value ) |
A shorthand for write()
Definition at line 100 of file mbed-dev/api/DigitalOut.h.
DigitalOut& operator= | ( | int | value ) |
A shorthand for write()
Definition at line 100 of file usb_cdc/mbed-dev/api/DigitalOut.h.
int read | ( | void | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- an integer representing the output setting of the pin, 0 for logical 0, 1 for logical 1
Definition at line 82 of file usb_cdc/mbed-dev/api/DigitalOut.h.
int read | ( | ) |
Return the output setting, represented as 0 or 1 (int)
- Returns:
- an integer representing the output setting of the pin, 0 for logical 0, 1 for logical 1
Definition at line 82 of file mbed-dev/api/DigitalOut.h.
void write | ( | int | value ) |
Set the output, specified as 0 or 1 (int)
- Parameters:
-
value An integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1
Definition at line 71 of file usb_cdc/mbed-dev/api/DigitalOut.h.
void write | ( | int | value ) |
Set the output, specified as 0 or 1 (int)
- Parameters:
-
value An integer specifying the pin output value, 0 for logical 0, 1 (or any other non-zero value) for logical 1
Definition at line 71 of file mbed-dev/api/DigitalOut.h.
Generated on Tue Jul 12 2022 22:19:22 by
