Include a limit switch to a Blynk project

Hello,

I am quite new to arduino, so I started with modifying existing codes to learn.

I am trying to build an automatic gate using this code: GitHub - makertut/servo-blynk-wifi

The servo is attached to a small gate, which can be opened/closed via blynk.
Basically I would like to include a limit switch, so whenever it is touched the servo automatically stops rotating (so I don't have to press 'stop').
Is this possible with an if-clause? Somebody told me this is only possible using a relay...

Thanks so much!

Yes, you can.

Have a nice day and enjoy programming in C++ and learning.

Thanks so much for your answer!
I tried to include this:

if(limitSwitch.isPressed)
Blynk.virtualWrite(V2, 0);

but it doesn't really work. I am also not sure where exactly to place it. Can you help me with this?

Best wishes