Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a potentiometer and how is it used in Arduino projects?
A potentiometer is a knob or dial that acts like a variable resistor. It changes the amount of electrical resistance when you turn it. In Arduino projects, it is used to give input by turning the knob, which changes the voltage read by the Arduino.
Click to reveal answer
beginner
Which Arduino function reads the value from a potentiometer?
The function analogRead(pin) reads the voltage from the potentiometer connected to an analog pin and returns a number between 0 and 1023.
Click to reveal answer
beginner
What is the range of values returned by analogRead() when reading a potentiometer?
The analogRead() function returns values from 0 to 1023. 0 means the lowest voltage (0 volts), and 1023 means the highest voltage (usually 5 volts).
Click to reveal answer
beginner
How do you connect a potentiometer to an Arduino for reading its value?
Connect one outer pin of the potentiometer to 5V, the other outer pin to GND, and the middle pin (wiper) to an analog input pin on the Arduino (like A0).
Click to reveal answer
beginner
What does the following Arduino code do?
int sensorValue = analogRead(A0);
This code reads the voltage from the potentiometer connected to analog pin A0 and stores the value (0 to 1023) in the variable sensorValue.
Click to reveal answer
What does the middle pin (wiper) of a potentiometer connect to in an Arduino circuit?
AAn analog input pin
B5V power supply
CGround (GND)
DDigital output pin
✗ Incorrect
The middle pin of the potentiometer connects to an analog input pin to read the variable voltage.
What is the maximum value returned by analogRead() on Arduino?
A255
B5
C1023
D512
✗ Incorrect
analogRead() returns values from 0 to 1023 representing voltage levels.
If you turn the potentiometer knob fully to one side, what value would you expect from analogRead()?
AAround 1023
BAround 0
CAround 512
DIt will be random
✗ Incorrect
Turning the knob fully to one side connects the wiper to ground, so the reading is near 0.
Which Arduino pin type is used to read a potentiometer value?
ADigital pin
BPower pin
CPWM pin
DAnalog pin
✗ Incorrect
Potentiometers output an analog voltage, so you must use an analog input pin.
What is the purpose of connecting the two outer pins of a potentiometer to 5V and GND?
ATo create a voltage divider for variable voltage output
BTo power the Arduino
CTo ground the Arduino
DTo connect sensors
✗ Incorrect
Connecting the outer pins to 5V and GND creates a voltage divider, so the middle pin outputs a voltage between 0 and 5V.
Explain how to connect and read a potentiometer value using Arduino.
Think about the hardware connections and the Arduino function used.
You got /4 concepts.
Describe what the value returned by analogRead() means when reading a potentiometer.
Consider how voltage changes with knob position.
You got /3 concepts.
Practice
(1/5)
1. What does the analogRead(pin) function do when reading a potentiometer on Arduino?
easy
A. It reads the voltage level on the analog pin and returns a value from 0 to 1023.
B. It sets the output voltage of the pin to control the potentiometer.
C. It converts a digital signal to an analog voltage.
D. It resets the potentiometer to zero position.
Solution
Step 1: Understand analogRead function
The analogRead(pin) reads the voltage on the specified analog pin and converts it to a number between 0 and 1023.
Step 2: Relate to potentiometer reading
Since a potentiometer outputs a variable voltage depending on its position, analogRead returns a value representing that voltage level.
Final Answer:
It reads the voltage level on the analog pin and returns a value from 0 to 1023. -> Option A
Quick Check:
analogRead() returns 0-1023 value [OK]
Hint: Remember analogRead returns 0-1023 for voltage levels [OK]
Common Mistakes:
Thinking analogRead sets voltage instead of reading it
Confusing analogRead with digitalRead
Assuming analogRead returns voltage in volts
2. Which of the following is the correct syntax to read a potentiometer connected to analog pin A0 and store the value in a variable named sensorValue?
easy
A. sensorValue = analogWrite(A0);
B. sensorValue = digitalRead(A0);
C. sensorValue = analogRead(A0);
D. sensorValue = readAnalog(A0);
Solution
Step 1: Identify correct function for analog input
The function to read analog input is analogRead(pin), not digitalRead or analogWrite.
Step 2: Check variable assignment syntax
Assigning the result of analogRead(A0) to sensorValue uses the syntax: sensorValue = analogRead(A0);
Final Answer:
sensorValue = analogRead(A0); -> Option C
Quick Check:
Use analogRead() to read analog pin [OK]
Hint: Use analogRead(pin) to read analog sensors [OK]
Common Mistakes:
Using digitalRead instead of analogRead
Using analogWrite which is for output
Using a non-existent function readAnalog
3. What will be printed on the Serial Monitor when the following Arduino code runs and the potentiometer is turned to mid position?
The code uses Serial.print(sensorValue) without a newline, causing consecutive values to print on the same line and appear garbled or unreadable.
Step 2: Use println for readability
Serial.println(sensorValue) adds a newline after each value, making the output clear on the Serial Monitor.
Final Answer:
Missing Serial.println instead of Serial.print -> Option A
Quick Check:
Serial.print vs println for newlines [OK]
Hint: Use Serial.println() not print() for readable output [OK]
Common Mistakes:
Using numeric 0 instead of A0 for analogRead
Confusing Serial.print and Serial.println
Ignoring delay causing fast output
5. You want to read a potentiometer and map its 0-1023 value to a 0-255 range to control LED brightness using PWM on pin 9. Which code snippet correctly does this?
hard
A. int sensorValue = analogRead(9);
int brightness = map(sensorValue, 0, 255, 0, 1023);
analogWrite(A0, brightness);
B. int sensorValue = analogRead(A0);
int brightness = map(sensorValue, 0, 1023, 0, 255);
analogWrite(9, brightness);
C. int sensorValue = digitalRead(A0);
int brightness = sensorValue * 255;
analogWrite(9, brightness);
D. int sensorValue = analogRead(A0);
int brightness = sensorValue / 4;
digitalWrite(9, brightness);
Solution
Step 1: Read potentiometer value correctly
Use analogRead(A0) to get a value from 0 to 1023.
Step 2: Map value to 0-255 for PWM
Use map(sensorValue, 0, 1023, 0, 255) to convert the range for LED brightness.
Step 3: Write PWM value to LED pin
Use analogWrite(9, brightness) to set LED brightness on pin 9.
Final Answer:
int sensorValue = analogRead(A0);
int brightness = map(sensorValue, 0, 1023, 0, 255);
analogWrite(9, brightness); -> Option B
Quick Check:
Read analog, map range, write PWM [OK]
Hint: Use map() to convert 0-1023 to 0-255 for PWM [OK]