Certainly using the micro switch/leaver switch is the simplest way. In case if you don't want to use mechanical approach, you can do this with IR proximity sensor as well.
Certainly using the micro switch/leaver switch is the simplest way. In case if you don't want to use mechanical approach, you can do this with IR proximity sensor as well.