Analog Input
Anand RamaswamiShare
Welcome Back, Maker!
So far we have been working with digital signals that are either ON or OFF, HIGH or LOW.
But the real world does not work that way.
A light does not just go from completely dark to fully bright. A knob does not just jump from minimum to maximum. These things change smoothly and continuously.
That kind of signal is called an analog signal.
What Is an Analog Signal?
A digital signal has only two states — HIGH or LOW.
An analog signal can be any value in between.
For example, the potentiometer on your NanoMake Pro produces a voltage anywhere between 0V and 5V depending on how far you turn the knob. That changing voltage is an analog signal.
|
Signal Type |
Possible Values |
Example |
|
Digital |
Only HIGH or LOW |
Button press |
|
Analog |
Any value in between |
Potentiometer knob |
Since analog signals need special pins to be read, the next step is to see which analog pins are available on the NanoMake Pro.
Analog Pins on the NanoMake Pro
On the NanoMake Pro, analog pins are already connected to onboard components:
A6 → Potentiometer
A7 → LDR (Light Sensor)
A0 → Sensor Port 1
A1 → Sensor Port 2
A2 → Sensor Port 3
A3 → Sensor Port 4
Now that we know which pins can read analog signals, we need a command that actually reads the value from those pins. That command is analogRead().
The Command: analogRead()
analogRead() is the command used to read a value from an analog pin.
Syntax:
|
analogRead(pin); |
Parameters:
- pin → the analog pin to read from (A6, A7, etc.)
Returns: a number between 0 and 1023.
The Arduino converts the voltage on the pin into a number:
|
Voltage on Pin |
Value Returned |
|
0V |
0 |
|
2.5V |
~511 |
|
5V |
1023 |
So when you turn the potentiometer all the way in one direction, analogRead() returns 0. Turn it all the way in the other direction and it returns 1023. Anywhere in between gives you a number proportional to the knob position.
Now that we know how analog reading works, let us see it in action through some projects.
Project 1: Read Potentiometer Value on Serial Monitor
Before we start the code, let us first understand what the potentiometer is doing.
What Is a Potentiometer?
A potentiometer is a variable resistor — a knob that changes resistance when you turn it.
On the NanoMake Pro the potentiometer has three connections:
- One outer pin goes to GND
- The other outer pin goes to 5V
- The middle pin goes to A6
When you turn the knob, the middle pin picks up a different voltage between 0V and 5V. The Arduino reads this voltage using analogRead() and converts it into a number between 0 and 1023.In this project we will read the raw value from the potentiometer and print it on the Serial Monitor. As you turn the knob the number changes in real time.
This is the simplest way to see analog input working, you can watch the numbers change as you turn the knob.
Code:
|
void setup() { Serial.begin(9600); // Start serial communication } void loop() { int sensorValue = analogRead(A6); // Read potentiometer Serial.println(sensorValue); // Print the value delay(200); } |
Explanation:
Serial.begin(9600) starts communication between the Arduino and the Serial Monitor.
analogRead(A6) reads the current voltage on pin A6 and converts it into a number between 0 and 1023.
Serial.println(sensorValue) prints the value on the Serial Monitor.
delay(200) waits 200 milliseconds before reading again so the output is easy to read.
Open the Serial Monitor and turn the potentiometer knob slowly. Watch the number increase from 0 to 1023 as you turn it one way and decrease back to 0 as you turn it the other way.
This first project shows the most basic use of analog input: reading a changing value.
Output:

Once you can read that value, the next step is to use it to control something.
Project 2: Potentiometer Controls LED Blink Rate
In this project the potentiometer controls how fast the LED blinks. Turn the knob one way and the LED blinks faster. Turn it the other way and the LED blinks slower.
The analog value read from the potentiometer is used directly as the delay time for the blink cycle. The higher the value, the longer the delay, the slower the blink. The lower the value, the shorter the delay, the faster the blink.
Code:
|
void setup() { pinMode(9, OUTPUT); // LED connected to pin 9 Serial.begin(9600); } void loop() { int sensorValue = analogRead(A6); // Read potentiometer value Serial.println(sensorValue); // Print the value digitalWrite(9, HIGH); // LED ON delay(sensorValue); // Wait based on knob position digitalWrite(9, LOW); // LED OFF delay(sensorValue); // Wait based on knob position } |
Explanation:
analogRead(A6) reads the potentiometer value between 0 and 1023 and stores it in sensorValue.
Serial.println(sensorValue) prints the current value so you can see it changing on the Serial Monitor while the LED blinks.
digitalWrite(9, HIGH) turns the LED ON.
delay(sensorValue) uses the potentiometer reading directly as the delay time in milliseconds. If the knob reads 1000, the LED stays ON for 1 second. If it reads 100, the LED stays ON for only 0.1 seconds.
digitalWrite(9, LOW) turns the LED OFF and waits the same amount of time before repeating.
The value is read once at the beginning of each cycle so the ON and OFF times are always equal. Turn the knob while the LED is blinking and watch the blink speed change.
So now we are doing more than just reading analog input — we are using it to control output behavior.
Output:

The same idea can also be used with other analog sensors, such as the LDR.
Project 3: LDR Controls LED Blink Rate
Before looking at the code, let us first understand what an LDR does.
What Is an LDR?
An LDR is a Light Dependent Resistor — a sensor that changes its resistance based on how much light falls on it.
- More light → lower resistance → higher voltage → higher ADC value
- Less light → higher resistance → lower voltage → lower ADC value
On the NanoMake Pro the LDR is connected to A7. You can read its value exactly the same way as the potentiometer using analogRead(A7).
In this project the LDR light sensor controls how fast the LED blinks. Cover the LDR with your finger and the LED blinks slowly. Shine a light on it and the LED blinks faster.
This works exactly the same way as Project 2 . The only difference is we are reading from the LDR on pin A7 instead of the potentiometer.
Code:
|
void setup() { pinMode(9, OUTPUT); // LED connected to pin 9 Serial.begin(9600); } void loop() { int ldrValue = analogRead(A7); // Read LDR value Serial.println(ldrValue); // Print the value digitalWrite(9, HIGH); // LED ON delay(ldrValue); // Wait based on light level digitalWrite(9, LOW); // LED OFF delay(ldrValue); // Wait based on light level } |
Explanation:
analogRead(A7) reads the light level from the LDR sensor on pin A7. The value will be between 0 and 1023 depending on how much light falls on the sensor.
Serial.println(ldrValue) prints the current light reading so you can monitor it on the Serial Monitor.
delay(ldrValue) uses the light level reading as the delay time. In bright light the LDR gives a high value so the LED blinks slowly. In darkness the LDR gives a low value so the LED blinks quickly.
Output:
This project shows that analog input is not limited to knobs. It also lets the Arduino react to real-world conditions like light.
Real-Life Examples of Analog Input
Analog input is everywhere in the real world.
When you turn the volume knob on a speaker, the knob is a potentiometer producing a changing voltage. The amplifier reads that voltage as an analog input and adjusts the volume accordingly. That is analog input.
When a plant watering system checks if the soil is dry, it reads a moisture sensor that produces a changing voltage depending on how wet the soil is. That is analog input.
When a car dashboard shows the fuel level, a float inside the fuel tank is connected to a variable resistor. As the fuel level drops, the resistance changes, the voltage changes, and the gauge reads it as an analog input. That is analog input.
The common idea in all of these is simple , a physical quantity changes a voltage, and the microcontroller reads that voltage as a number it can work with.
Why Analog Input Is Important
Without analog input, your Arduino can only detect two states — ON or OFF.
With analog input it can detect thousands of levels in between. This allows you to build projects that respond to the real world in a smooth and natural way.
Once you understand analog input you can read any sensor that produces a changing voltage , temperature sensors, light sensors, sound sensors, pressure sensors, and much more.
Final Thoughts
Analog input is how your Arduino connects to the real world.
Every time you call analogRead(), the board is measuring a real physical voltage and handing you a number between 0 and 1023. That number represents something happening in the real world like a knob position, a light level, a temperature.
Now that you understand how analog input works, your projects can go far beyond simple ON and OFF control.
Keep experimenting, keep building, and keep making.