Example Code for Arduino-Analog Read

Last revision 2026/01/24

This guide walks you through using Arduino to perform analog reads, detailing hardware and software setups with Intel Edison, and includes sample code to read sensor data from pin A0, displaying results in the serial monitor.

Hardware Preparation

Software Preparation

Other Preparation Work

  1. Download and install the DFRobot_Edison library V1.1 (required for Atmel mega 8 analog pin driver).
  2. Open Arduino IDE, select Tools --> Board --> Intel Edison and Tools --> Serial Port --> COM xx.

As Romeo for Edison is using ATmega 8 as Analog pins driver. Please download the DFRobot4Edison library first. The library is keeping update, so some sample code and picture will be different to the old one.

Sample Code

Import two libs, init Serial 9600, read A0 analog value and print periodically.

#include <DFRobot.h>
#include <IIC1.h>

unsigned int value = 0;

void setup() {
 Serial.begin(9600);
}

void loop() {

  value = analogRead(A0);

  Serial.println((int)value);

  delay(2000);
}

Result

The analog value from pin A0 is printed to the serial monitor every 2 seconds.

DFR0331_Analog_value.png

Was this article helpful?

TOP