Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Learning the basics about analog inputs of an industrial PLC


On this post, we are going to explain how to do the basics in order to work with analog inputs of Industrial Shields' programmable logic controllers. Reading this post, you will be able to understand how to connect and configure the analog inputs of your industrial Arduino PLC controller.

Previous reading

We recommend you to read the following blogs in order to understand the program of this blog. We used the following blog posts to do this example:


In order to work with analog inputs you will need any of our industrial controllers for industrial automation:

Configuring the switches

Most of the analog inputs are always connected to the internal Arduino, but in a few cases, the user can choose between a special peripheral configuration or a GPIO by changing the position of the Dip Switches .

Each switch can select only one configuration. For example, in this case we are watching the GPIOs configuration of a M-Duino 57R+. If we put the switch to the right position (ON) in the upper one, the input I2.1 will be activated and we will be able to work with this as input. If the switch is in the left position (OFF) we will activate the SCL line which will be used for I2C communication. Keep in mind each switch has two different configurations: you must select the right (ON) or the left (OFF) option.

Odoo - Sample 1 for three columns

I2.1 input enabled - SCL disabled


Odoo - Sample 2 for three columns

I2.1 input disabled- SCL enabled

Input types

 In all of the Industrial Shields Arduino based PLCs, analog inputs can work at:

  • 0V - 10V analog input

Analog inputs have a special draw in the case of the PLC:

Odoo - Sample 2 for three columns

0V - 10Vdc Analog input



All the analog inputs are not opto-isolated (they use the same GNDs as the PLC). The following image shows how to connect an analog input to the PLC:

Odoo - Sample 2 for three columns

0V - 10Vdc Analog input



In order to program the analog GPIOs, we must keep in mind that we can read the values with the following command:


This function returns a value between 0 and 1023 depending on the applied voltage level to the input (0V it is equal to 0, and 10V it is equal to 1023).

GPIO is the name of the input. Imagine we want to know the state of the "I0.12" input, then, we must write this line: 


We must know we do not need to configure the analog inputs as analog. Industrial Shields' libraries do all the work for us.


You can see a read analog GPIO example in the following paragraph:

// Analog read example
// This example reads the I0_12 and shows via serial the value

// Setup function
void setup()
    // Set the speed of the serial port

// Loop function
void loop()
    int value = analogRead(I0_12);

Basics: Analog inputs in Arduino PLC

Do you want more information?

Just fill the form!

Tell me more!