Analog Read Serial
Intro
This example shows you how to read analog input from your NEXTuino device over serial communication. Connect a potentiometer to one analog input and establish serial communication between your NEXTuino board and your computer running the Arduino Software (IDE).
IMPORTANT: Please select the proper target board in Tools > Board > NEXTuino RISE/MAXI/MEGA before uploading to your NEXTuino.
Hardware Required
- NEXTuino RISE/MAXI/MEGA
- 10k ohm potentiometer
Code
#include <NEXTuino.h>
// the setup routine runs once when you press reset:
void setup() {
// initialize the necessary pin as an input pin
pinMode(NEXTuino_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(NEXTuino_A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
Note: The pin header is working on 5V TTL levels. Voltage levels over 5.5V can damage the NEXTuino permanently.