Problem About ADC Reading Potentiometer

Hi Im New to arduino

I tried to read the value of my potentio adc through the serial number, but the number changes, for example, if I set the output value to 200, the value in the serial number display is in the range of 200-201-202, is there a way to make it stable and not change?

this is my program

#include <Stepper.h>
#define STEPS 200
Stepper stepper(STEPS, 2, 3);
#define motorInterfaceType 1
int adc = A0;
int dirPin = 2;
int stepPin = 3;
int buzz = 4;
void setup() {
pinMode (dirPin,OUTPUT);
pinMode (buzz,OUTPUT);

void loop() {
int adc = analogRead (A0);

Serial.println (adc);
if (adc < 1000)
digitalWrite (dirPin, HIGH);
digitalWrite (buzz,LOW);

else {
digitalWrite (dirPin, LOW);
digitalWrite (buzz,HIGH);


Try putting a 0.1uF ceramic cap from the wiper of the pot to ground to filter noise. It is normal for there to be a 1 or 2 bit jitter in the ADC output. You may not be able to make it dead stable.

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

You can add a capacitor at the input of the A/D pin but this will slow things down but not stop them from changing.

Every analog signal has electrical "noise" on it. The trace depicts noise on a signal. When the A/D converter "reads" the signal some of that noise gets factored in. It can be reduced but cannot be eliminated.
This is why the world has gone to mostly digitized signals.

If you absolutely need a stable signal, look into encoders.

How are you powering the stepper.
Can you please post a link to data/specs of the stepper and the driver?
Can you please post a copy of your circuit diagram?

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

how to use that encoder signal?

i use nema 17. 1.8 degree step, 1.2 Amps, 200 steps per revolution
im using 12 volt dc to run the motor and the driver
you can fiind it on google how to wire bipolar stepper motor with A4988 driver


What current is it rated for?

No, please post your circuit diagram.....
Get out pen(cil) and paper.

A picture of your project would also help.

Tom.. :grinning: :+1: :coffee: :australia:

wait xd, sorry :slight_smile: