Help with sensor light switch

Hey guys

How can I make a light switch sensor so it works like this: When sensor detects movement like someone walk in a room to switch light on and again when someone leave room to switch light off? To keep it on all the time until detects another movement?

Really appreciate it

It sounds like a classic application for a passive infra red (PIR) sensor.