HC-SR04 & 2 SERVOS MULTITASKING

Hello there! This is my case
I´ve been trying to make ServoX and ServoY work simultaneously:

ServoX: Sweeps a 180° in 3 seconds, back and forth without stopping (first i wanted to make a 1 second stop before moving in the other direcion, but it was too complicated to me)

ServoY: moves from 90 to 180 degrees depending on the distance read by the sensor, I used the map and constrain functions.

The two servos work well separately, and as expected, the problem comes when "fusing" them, I even learned how tu use the millis function instead of delay.

Could someone check the code please?

ULTRASERVO_V2.ino (1.36 KB)

If you post your code as described in the how to use this forum-please read sticky more members will see it.

Your answer will involve timing using the millis() function.

There's a sticky thread near the top of the Project Guidance page that shows how to do multiple things at once.