Function to configure a pin as Input/Output - Arduino IDE

December 5, 2018 by
Function to configure a pin as Input/Output - Arduino IDE
Alejandro Jabalquinto

Introduction

In this post, it will be shown the function to configure a pin as Input/Output using Arduino IDE.


Requirements

Ethernet or 20 I/Os PLC:      Ethernet PLC      20 I/Os PLC     

Industrial Shields boards:   Industrial Shields Boards

Description

The function to configure a pin as IN/OUT using Arduino IDE is pinMode(). This function is used to configure an Arduino pin as an input or as an output. On Industrial Shields equipment’s is followed with the corresponding Pin-out. This function is normally used inside the setUp() function.

*With the next version of Industrial Shields boards won’t be necessary to configure the pins, just selecting the proper board, I/O’s will be automatically configured.   

Next is showed the syntax:

pinMode(pin, mode);

Pin: Could be any industrial shields equipment pin or any Arduino board pin that you wish to set. 

Mode: INPUT, OUTPUT or INPUT_PULLUP (See more information on Arduino references)


Example

Code Example, blinking of two digital outputs:

void setup() {
  pinMode(Q0_0, OUTPUT); // configure Q0.1 as a OUTPUT
  pinMode(Q0_1, OUTPUT);
}

void loop() {
  digitalWrite(Q0_0, HIGH); // set to HIGH Q0.0 and Q0.1
  digitalWrite(Q0_1, HIGH);
  delay(1000);             // delay 1s
  digitalWrite(Q0_0, LOW); // set to LOW Q0.0 and Q0.1
  digitalWrite(Q0_1, LOW);
  delay(1000);
}

​Search in our Blog

Function to configure a pin as Input/Output - Arduino IDE
Alejandro Jabalquinto December 5, 2018

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>