Analog Read Serial


Analog Read Serial

This example shows you how to read analog input from your Controllino device over serial communication. In order to do this, you have to connect potentiometer on one analog input and establish serial communication between your Controllino board and your computer running the Arduino Software(IDE).

IMPORTANT INFORMATION!
Please, select proper target board in Tools->Board->Controllino MINI/MAXI/MEGA before Upload to your CONTROLLINO.
(Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in the Arduino IDE menu Tools->Board.)

Hardware Required

  • Controllino MINI/MAXI/MEGA
  • 10k ohm potentiometer

Circuit

 or 

Note*
Pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the Controllino permanently.

Code

#include <Controllino.h> 
/* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */

// the setup routine runs once when you press reset:
void setup() {
    // initialize necessary pin as input pin
    pinMode(CONTROLLINO_A0, INPUT);
 
    // initialize serial communication at 9600 bits per second:
    Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
    // read the input on analog pin 0:
    int sensorValue = analogRead(CONTROLLINO_A0);
    // print out the value you read:
    Serial.println(sensorValue);
    delay(1); // delay in between reads for stability
}

Download File

AnalogReadSerial.ino