version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of mbed by
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. | |
operator int () | |
An operator shorthand for read() |
Detailed Description
A digital input, used for reading the state of a pin.
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 46 of file 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 53 of file 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 62 of file DigitalIn.h.
Member Function Documentation
void mode | ( | PinMode | pull ) |
Set the input pin mode.
- Parameters:
-
mode PullUp, PullDown, PullNone, OpenDrain
Definition at line 79 of file DigitalIn.h.
operator int | ( | ) |
An operator shorthand for read()
Definition at line 86 of file 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 71 of file DigitalIn.h.
Generated on Thu Jul 14 2022 10:44:07 by 1.7.2