help with motor control code

hi guys,
is here someone that can give me a hand with the code to command a motor to turn 90 degrees clockwise and command it to turn back again? im building an arcade cabinet and im trying to emulate this design.
any help would be appreciated

What microcontroller are you using for commanding the motor? What type of motor do you have?

You will need something to measure the 90 degree turn.

Multiple choices here:

  1. Integrated motor encoder
  2. Potentiometer - only goes 270 degrees
  3. Older red Quadrature encoder
  4. Gyroscope sensor

You then want to figure out how many ticks or potentiometer reading means 90 degrees. Or the gyro reads 90 degrees. Then you need some code to get you to your target effectively and not over or undershoot. You want your motor to slow down and glide into 90 degrees. Otherwise momentum will carry you further than you want.

Start with this P controller. You want a turn versus arm height but the concept is exactly the same. Once you master this, you can decide if you want to get fancier.

Limit switches would work, just mount one at the stopping point. I would use a limit switch and an encoder, the limit switch would set the encoder to zero.

Thanks everybody for replying. i have
2 wire motor 393
2 limit switches
motor controller 29

this is what im building

Hmmm. You look like Arduino is you thing. Not sure where the motor is on this thing and what kinds of options you have for detecting the position.

A gyro may be your best bet. but they are expensive.

I did it in PROS using the compas.