api / mbed / trunk / DigitalIn

DigitalIn

class DigitalIn : public Base

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);
    }
}
DigitalInA digital input, used for reading the state of a pin
Functions
DigitalInCreate a DigitalIn connected to the specified pin
readRead the input, represented as 0 or 1 (int)
modeSet the input pin mode
operator int()An operator shorthand for read()

Functions

DigitalIn

DigitalIn(PinName pin,  
const char *name =  NULL)

Create a DigitalIn connected to the specified pin

Variables

pinDigitalIn pin to connect to
name(optional) A string to identify the object

read

int read()

Read the input, represented as 0 or 1 (int)

Variables

returnsAn integer representing the state of the input pin, 0 for logical 0 and 1 for logical 1

mode

void mode(PinMode pull)

Set the input pin mode

Variables

modePullUp, PullDown, PullNone, OpenDrain

operator int()

operator int()

An operator shorthand for read()

class DigitalIn : public Base
A digital input, used for reading the state of a pin
DigitalIn(PinName pin,  
const char *name =  NULL)
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()