It is possible to connect external components to the mbed boards. To communicate with them in your program, you can use the classes AnalogIn, AnalogOut, DigitalIn and DigitalOut, depending on the type of component.
An LED light may for instance be controlled through DigitalOut, like this:
Here, we define a new variable of the kind DigitalOut, by passing in what pin the LED is connected to. The LED light may be turned on and off by settings the variable myled to 1 and 0 respectively.
DigitalOut and the other classes may be used for components both on and off the board. The only thing that's different is what pin you refer to in the initialization.
Some components send analog signals and then you need to use the AnalogIn/AnalogOut classes. An example of such a component may be a rotating knob, sending continous values corresponding to its rotation.
Here we have connected an analog component to the pin labelled P06.
To read the current value of 'mything', write:
float value = mything.read();
More information on the different mbed classes can be found at developer.mbed.org: