You are viewing an older revision! See the latest version

DigitalInOut

Table of Contents

  1. Hello World!
  2. API
  3. Related

/media/uploads/mbedofficial/digitalin_interfaces.png

The DigitalInOut interface is used as a bi-directional digital pin, used to read the value of a digital pin when set as an input, or write the value when set as an output.

Any of the numbered mbed pins can be used as a DigitalInOut.

Hello World!

Reset a 1-Wire device

 
#include "mbed.h"

DigitalInOut pin(p5);

int main() {
    pin.output();
    pin = 0;     
    wait_us(500);
    pin.input();
    wait_us(500);
}

API

API summary

Import library

Public Member Functions

DigitalInOut (PinName pin, const char *name=NULL)
Create a DigitalInOut 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)
void output ()
Set as an output.
void input ()
Set as an input.
void mode (PinMode pull)
Set the input pin mode.
DigitalInOut & operator= (int value)
A shorthand for write()
operator int ()
A shorthand for read()
virtual struct rpc_method * get_rpc_methods ()
Returns a pointer to an array describing the rpc methods supported by this object, terminated by either RPC_METHOD_END or RPC_METHOD_SUPER(Superclass).
void register_object (const char *name)
Registers this object with the given name, so that it can be looked up with lookup.
const char * name ()
Returns the name of the object.
virtual bool rpc (const char *method, const char *arguments, char *result)
Call the given method with the given arguments, and write the result into the string pointed to by result.

Static Public Member Functions

static bool rpc (const char *name, const char *method, const char *arguments, char *result)
Use the lookup function to lookup an object and, if successful, call its rpc method.
static Base * lookup (const char *name, unsigned int len)
Lookup and return the object that has the given name.
template<class C >
static void add_rpc_class ()
Add the class to the list of classes which can have static methods called via rpc (the static methods which can be called are defined by that class' get_rpc_class() static method).

All wikipages