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

How to write an Analog Output - Arduino IDE


Introduction

In this post it will be shown how to write an Analog output with the Arduino IDE interface.


Requirements

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

Industrial Shields boards:   Industrial Shields Boards


Description

The function for writing in an analog output using Arduino IDE is AnalogWrite().  This function is used to set an analog output from 0 to 255.

 On Industrial Shields equipment’s is followed with the corresponding pinout. This functions are normally used inside the loop() function.

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


Next is showed the syntax:

AnalogWrite(pin, value);

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

Value: 0 to 255(See more information on Arduino references)


Example

Code Example, blinking of an analog outputs:

void setup() {
  pinMode(A0_5, OUTPUT); // configure A0.5 as OUTPUT
}

void loop() {
  analogWrite(A0_5, 0);
  delay(1000);             // delay 1s
  digitalWrite(A0_5, 255); 
  delay(1000);
}


Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send