/*
Arduino | esp-help
moven November 15, 2025 10:45 PM
hello, i have a circuit running two digital servos with
a joystick using an esp32 dev board, but the joystick
produces an incredibly erratic amount of noise
*/
#include <ESP32Servo.h>
Servo lookLR; // create servo object to control a servo
Servo lookUD; // create servo object to control a servo
int UDPin = 34;
int LRPin = 35;
int UDState = 90;
int LRState = 90;
// twelve servo objects can be created on most boards
int pos = 90; // variable to store the servo position
void setup() {
Serial.begin(9600); // Uncommented to enable serial output
lookLR.attach(18);
lookUD.attach(19);
}
void loop() {
UDState = map(analogRead(UDPin), 0, 4095, 40, 140);
LRState = map(analogRead(LRPin), 0, 4095, 40, 140);
// Print raw joystick values
Serial.print("UD Raw: ");
Serial.print(analogRead(UDPin));
Serial.print(" | LR Raw: ");
Serial.println(analogRead(LRPin));
lookUD.write(UDState);
lookLR.write(LRState);
}