Arduino-Digital I/O Function

This article details the use of Arduino's Digital I/O functions.

The Digital I/O functions allow the Arduino board to output and input digital signals.

For other Arduino functions and libraries, please refer to the following article.

TOC

Digital I/O Functions

FunctionsParametersReturnsExplanation
void pinMode(pin, mode)pin: The digital pin number to set
mode: INPUT, OUTPUT, or INPUT_PULLUP
NoneConfigures the pin to be input, output, or pullup
void digitalWrite(pin, value)pin: The digital pin number to set
value: HIGH or LOW
NoneWrite HIGH or LOW to the digital pin
int digitalRead(pin)pin: The digital pin number to setHIGH or LOWReads HIGH or LOW from the digital pin

pinMode()/Configures the pin to be input, output, or pullup

pinMode()/Configures the pin to be input, output, or pullup
  • Function: void pinMode(pin, mode)
  • Parameter: pin⇒The digital pin number to set
  • : mode⇒INPUT, OUTPUT, or INPUT_PULLUP
  • Return: None

The pinMode() function switches the mode of digital I/O by setting "pin number" and "mode" as parameters.

The mode can be selected from "INPUT", "OUTPUT", and "INPUT_PULLUP".

digitalWrite()/Write HIGH or LOW to the digital pin

digitalWrite()/Write HIGH or LOW to the digital pin
  • Function: void digitalWrite(pin, value)
  • Parameter: pin⇒The digital pin number to set
  • : value⇒HIGH or LOW
  • Return: None

The digitalWrite() function performs digital output by setting "pin number" and "output voltage" as parameters. The output voltage can be "HIGH" or "LOW".

digitalRead()/Reads HIGH or LOW from the digital pin

digitalRead()/Reads HIGH or LOW from the digital pin
  • Function: int digitalRead(pin)
  • Parameter: pin⇒The digital pin number to set
  • Return: HIGH or LOW

The digitalRead() function is used to perform digital input by setting a "pin number" as an parameter.

The input voltage status returns "HIGH" for 5V and "LOW" for 0V.

Sample Programs (Sample Sketches)

Sample programs that use Digital I/O functions to move electronic parts such as LEDs and switches are introduced.

LED (Light Emitting Diode)

Blinking LED is programmed in the Digital I/O functions.

Switch

The input state of the switch is read by a program using Digital I/O functions.

Let's share this post !
TOC