hello everybody,
i am working on project in which joystick is used to control two bipolar stepper motors with A4988 drivers. But the problem is output of the ADC from both x axes and y axes pins is fluctuating . For x axis pin it is between 514 and 516 and for y axis pin it is between 519 to 521.
when joystick is at rest position.
This is the code i am using :
int joyPin1 = 0; // slider variable connecetd to analog pin 0
int joyPin2 = 5; // slider variable connecetd to analog pin 5
int value1 = 0; // variable to read the value from the analog pin 0
int value2 = 0; // variable to read the value from the analog pin 1
void setup() {
Serial.begin(9600);
}
void loop() {
value1 = analogRead(joyPin1);
delay(10);
value2 = analogRead(joyPin2);
Serial.print("x value :");
Serial.print(value1);
Serial.print(" ");
Serial.print("y value :");
Serial.println(value2);
delay(1000);
}
i have tested the above code on the following boads
- Arduino Uno clone
- simple atmega328p with usbasp as programmer on perfboard
- original Arduino Leonardo
Only original Arduino Leonardo is giving clean ADC output with value of 515 for x axis and 520 for y axis when joystick is at rest .
atmega328p with usbasp as programmer has more noisy outputs than my Arduino UNO clone.
Is this a known problem with ADC of arduino Uno ?
Is there any special circuitry on Arduino Leonardo for noise Reduction ?