HOW TO WRITE AN ANALOG OUTPUT. ARDUINO IDE

HOW TO WRITE AN ANALOG OUTPUT. ARDUINO IDE

Before writing an analog output it is needed to set the pin as OUTPUT. See the following post to configure a pin.

Function to configure a pin as INput/OUTput. Arduino IDE

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 setup() 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)

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);
}

SEE ALSO: HOW TO USE THE MAPPING PINS OF INDUSTRIAL SHIELDS BOARDS

 

Los comentarios están cerrados