28BYJ-48 stepper motor

hello, I'm working on a new project and I'm using this small stepper motor from yourduino.com. I'm controlling the position of the stepper motor using a 10K potentiometer and it does rotates according to the pot, but it jitters at any position. What could be cousing this jittering?. I tried the knob code from arduino.cc and still jitters. I replaced the pot with a 1.2 kohms fix resistor and it does not jitters when stoped. Is the code missing something? HELP, no really HELP.

#include STEPS 100

Stepper stepper(STEPS,8,10,9,11);

int previous = 0;

void stup ()


stepper.setSpeed (160);


void loop ()


int val = map (analogRead(0), 0, 1023, 0, 2046); // 2046 will turn the stepper motor 1 full revolution to 180 degrees of pot's turn.

stepper.step(val - previous);

previous = val;


Have you ever

scaled up an image by 200% and seen that it was jaggy? You are doing something similar with your map() function call. No matter where the pot is set, it will likely be between 2 points. All your program does is constantly read the pot position and update the stepper. I believe a delay of 1/2 second to 1 second would diminish the jitter. Better yet, try stepper.step((analogRead(0) * 2) - previous);