DigitalIn
This content relates to a deprecated version of Mbed
Mbed 2 is now deprecated. For the latest version please see the Mbed OS documentation.
For the latest DigitalIn API, please see DigitalIn.
The DigitalIn interface is used to read the value of a digital input pin.
Any of the numbered mbed pins can be used as a DigitalIn.
Hello World!¶
[Repository '/users/mbed_official/code/DigitalIn_HelloWorld_FRDM-KL25Z/docs/tip/main_8cpp_source.html' not found]
API¶
API summary
Import librarymbed
Interface¶
The DigitalIn Interface can be used on any pin with a blue label.
The pin input is logic '0' for any voltage on the pin below 0.8v, and '1' for any voltage above 2.0v. By default, the DigitalIn is setup with an internal pull-down resistor.
See the Pinout page for more details |
Related¶
To handle an interrupt, see InterruptIn
Examples of logical functions
Boolean logic - NOT, AND, OR, XOR
#include "mbed.h" DigitalIn a(p5); DigitalIn b(p6); DigitalOut z_not(LED1); DigitalOut z_and(LED2); DigitalOut z_or(LED3); DigitalOut z_xor(LED4); int main() { while(1) { z_not = !a; z_and = a && b; z_or = a || b; z_xor = a ^ b; } }