1:56 AM
For simple feedback signals at both ends of the motor 180 degrees journey, you might also like to consider Hall sensor and Reed switches.
(1) Magnetic hall sensor - AliExpress
https://www.aliexpress.com/w/wholesale-magnetic-hall-sensor.html

(2) Magnetic Reed Switch - AliExpress
https://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20220307175412&SearchText=reed+switch+

2:39 AM
This one is practical, with a drawer below for storing the folded shirts.
Semi-auto cloth folding machine using Arduino Uno, servo motor and flip fold- Polimas, 18,617 views
This one is academic, with a published paper
Cloth Folding Machine - WashU Project
https://openscholarship.wustl.edu/cgi/viewcontent.cgi?article=1089&context=mems411

3:04 AM
And Thermotron is impressive.
Automatic folding & bagging & sealing for casual clothes (STP950/PV38/KL55) - Thermotron 2010jun17, 159,350 views

4 hours later…
7:13 AM
Now I have written a program to move the motor 180 degrees 10 times.
After 10 half turns of 180 degrees each, the motor moves to its original position, with an offset of a couple of degrees.
The complete program list is as below.
Program moving motor 180 degrees 10 times: https://penzu.com/p/f783fc62

7:28 AM
Now the video. youtu.be/OsKmU_t5BiY
I read the OP''s program and found that he seems to forget to "fast stop" the motor. This is the fast stop function I am using:
```def l298nFastStopMotor(enblPinNum, in1PinNum, in2PinNum):
enblPin = gpOutPinDict[str(enblPinNum)]
in1Pin = gpOutPinDict[str(in1PinNum)]
in2Pin = gpOutPinDict[str(in2PinNum)]
setGpOutPinHigh(enblPin)
setGpOutPinHigh(in1Pin)
setGpOutPinHigh(in2Pin)
return```

4 hours later…
11:25 AM
The previous function moves 180 degrees x 2 = 360 degrees, but always in the same direction, and makes an offset of a couple of degrees from the home position.
Now if moving forward and backward, as specified by the OP, then the offset from home position is more than a couple of degrees (for ten repetitions). The reason is "black lash", as explained below.
The OP's motor has no gear, therefore no backlash problem. If he uses gear, then he has the back lash problem. As explained by the Oriental Motor, one way to prevent backalsh is to use stepper motor. Another workaround is to advance "a little bit first" when reversing the direction, so to compensate the backlash slack. However, the backlash magnitude might depend on the gear assembly, therefore not a good solution.
If not using stepper motor, a better solution is to use position/rotary sensors such as Hall or optical sensor. This would be explored/experimented next.

2 hours later…
1:13 PM
I am reading pico interrupt tutorials to refresh memory on how to use interrupts to read motor encoder signals and measure speed.
(1) Dual Cores & Interrupts on Pi Pico - Tony Gohew 2021mar25
https://www.instructables.com/Dual-Cores-Interrupts-on-Pi-Pico/

(2) Making a Rpi Pico Based Smart Vehicle (2021jun 13/27 to 18/27)
https://forum.pi-top.com/t/making-a-rpi-pico-based-smart-vehicle/924/28