DigitalInOut

mbed OS 2 and mbed OS 5

This is the handbook for mbed OS 2. If you’re working with mbed OS 5, please see the new handbook and API References. For the latest DigitalInOut API, please see DigitalInOut.

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!

Import program

00001 #include "mbed.h"
00002  
00003 DigitalInOut pin(p5);
00004  
00005 int main() {
00006     pin.output();
00007     pin = 0;     
00008     wait_us(500);
00009     pin.input();
00010     wait_us(500);
00011 }

[Not found]

API

API summary

Import library

Public Member Functions

  DigitalInOut (PinName pin)
  Create a DigitalInOut connected to the specified pin.
  DigitalInOut (PinName pin, PinDirection direction, PinMode mode, int value)
  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.
int  is_connected ()
  Return the output setting, represented as 0 or 1 (int)
DigitalInOut operator= (int value)
  A shorthand for write()
DigitalInOut operator= ( DigitalInOut &rhs)
  A shorthand for write()
  operator int ()
  A shorthand for read()

Interface

The DigitalInOut Interface can be used on any pin with a blue label.

/media/uploads/chris/pinout-thumbnails.jpg
See the Pinout page for more details