The Best DIY STEM Tutorials and Projects

Taking input From POT

OVERVIEW

In this project, we’ll learn how to take input from a potentiometer and read its values using Arduino! A potentiometer works like a volume knob, changing resistance as we turn it. We’ll see how Arduino captures this data and displays it, helping us understand how analog inputs work. Get ready to twist, turn, and explore! 🔄✨

You can follow this video and the instructions below.

Video

Program / Code

Code is Explained in the Comments of the Code

const int potPin = A0;   Potentiometer connected to analog pin A0
const int ledPin = 6;    LED connected to digital pin 7

void setup() {
  Serial.begin(9600);    Initialize serial communication at 9600 baud
  pinMode(ledPin, OUTPUT);  Set LED pin as output
}

void loop() {
  int potValue = analogRead(potPin);  Read potentiometer value (0-1023)
  Serial.println(potValue);  Print potentiometer value to Serial Monitor
  analogWrite(ledPin, potValue  4);  Set LED brightness (divide by 4 to fit PWM range)
  delay(100);  Small delay to prevent flooding the Serial Monitor
}

Thank you so much for going through our tutorial, we hope it was easy to follow and you enjoyed it, please share your feedback and pictures of the project (if you have made it) in the comments below .!

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *