DigitalOut

Table of Contents

  1. Hello World!
  2. API
  3. Interface

The DigitalOut interface is used to configure and control a digital output pin.

Hello World!

Import program

00001 #include "mbed.h"
00002 
00003 DigitalOut myled(LED1);
00004 
00005 int main() {
00006     while(1) {
00007         myled = 1;
00008         wait(0.2);
00009         myled = 0;
00010         wait(0.2);
00011     }
00012 }

API

API summary

Import library

Public Member Functions

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

Interface

The DigitalOut Interface can be used on any pin with a blue label, and also with the on-board LEDs (LED1-LED4)

The DigitalOut Interface can be used to set the state of the output pin, and also read back the current output state. Set the DigitalOut to zero to turn it off, or 1 to turn it on.

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