Pin I/O Theory

Pin I/O Theory

The SODAQ Mbili board has 10 digital (D4, D5, D6, D7, D10, D11, D18, D19, D20,В D21) and 6 analog pins (A0, A1, A2, A3, A4, A5) available for input via the Grove sockets. These pins are arranged in pairs per a Grove socket, the layout of which is shown here:
Grove sockets.

Note: There are additional pins which are not connected to the Grove sockets but which are used to control components on the SODAQ Mbili board (e.g. the onboard LEDs).

A digital signal consists of a set of two values represented in the Arduino language by the constants HIGH and LOW.  The analog signals consist of a range of values. For input, these signals are represented by a 10 bit unsigned integer with a range of 0…1023. For output, an 8bit unsigned integer is used with a range of 0…255.

Many of the available sensors and components use these pins for sending or receiving signals. Specific examples of using the digital and analog pins to read from sensors or to control attached components can be found on the examples pages listed in the tutorials menu.

Digital I/O

The digital pins can only be used for digital I/O while the analog pins can be used for both digital and analog I/O. A pin used in digital mode must be set to either INPUT or OUTPUT before it is used. This is done through a call to the method pinMode().

The following methods are used for digital I/O:

Analog I/O

The analog pins can be used in digital mode using the methods specified above. Additionally, they can be used for analog Input using the following methods:

  • analogRead(pin): Returns a 10bit unsigned integer (0…1023) specifying the analog reading from the specified pin.

Note: There is no need to set the pin mode when using any of the analog pins for analog I/O.