api / mbed / trunk / DigitalOut

DigitalOut

class DigitalOut : public Base

A digital output, used for setting the state of a pin

Example

// Toggle a LED
#include "mbed.h"

DigitalOut led(LED1);

int main() {
    while(1) {
        led = !led;
        wait(0.2);
    }
}
DigitalOutA digital output, used for setting the state of a pin
Functions
DigitalOutCreate a DigitalOut connected to the specified pin
writeSet the output, specified as 0 or 1 (int)
readReturn the output setting, represented as 0 or 1 (int)
operator=A shorthand for write
operator int()A shorthand for read

Functions

DigitalOut

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

Create a DigitalOut connected to the specified pin

Variables

pinDigitalOut pin to connect to

write

void write(int value)

Set the output, specified as 0 or 1 (int)

Variables

valueAn integer specifying the pin output value, 0 for logical 0 and 1 (or any other non-zero value) for logical 1

read

int read()

Return the output setting, represented as 0 or 1 (int)

Variables

returnsAn integer representing the output setting of the pin, 0 for logical 0 and 1 for logical 1

operator=

DigitalOut& operator= (int value)

A shorthand for write

operator int()

operator int()

A shorthand for read

class DigitalOut : public Base
A digital output, used for setting the state of a pin
DigitalOut(PinName pin,  
const char *name =  NULL)
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)
DigitalOut& operator= (int value)
A shorthand for write
operator int()
A shorthand for read