PFA:006 – Arduino Inputs & Outputs

screen-shot-2016-10-18-at-00-53-21

Digital Inputs and Outputs

  • The basic Arduino board has 14 digital pins that can be used either as inputs or outputs
  • Digital inputs are used to read buttons/switches and other digital signals
  • Digital outputs are used to control other electric components or devices (LEDs, motors etc.)
  • You set the pin as INPUT or OUTPUT with the pinMode() function

Analog Output

The basic Arduino board does not have real analog output, but some of the pins support PWM (pulse-width modulation). PWM lets us to “fake” an analog signal with digital outputs. It can be used to fade lights, control the speed of motors etc.

Analog Input

The Arduino Duemilanove/UNO/Leonardo boards have 6 analog inputs. They are 10-bit ADCs (analog-to-digital converters). The analog inputs are used to read analog sensors.

Logic Level and the Resolution of Inputs and Outputs.

Function 0V 5V
digitalRead() LOW (0) HIGH (1)
digitalWrite() LOW (0) HIGH (1)
analogRead() 0 1023
analogWrite() 0 255

Serial Communication

The Arduino uses a serial port to send/receive data between the board and the computer (or any other device that supports serial communication).