Vending machine with arduino Leonardo

Hello,

For a school project, I'm trying to make a vending machine, similar to this one:

I have the Servo Motor which turns 360 degrees and a PIR motion sensor, breadboard, and the Arduino Leonardo and cables and stuff. With all of this, I want to make a vending machine which will turn 360 degrees in 4 times when the PIR motion sensor detects a movement.
I want to put the PIR motion sensor on top of the vending machine, so when someone jumps or use their hands in front of the motion, the motor will turn 90 degrees. You have to move/jump/do something 4 times, so the vending machine's iron, where the candy is between it, will turn 360 degrees in total, so you receive your well-deserved candy.

I'm not very good with the code, but I guess I have to use an if/else statement, where you say; if the motion sensor detects motion, turn the motor 90 degrees. But, now I'm wondering how I do this four times a row, and how I connect the code of the motion sensor and the servo motor?

Can someone help me with this?

Is it absolutely neccesary use the PIR?