New electrical switch key code

Can you creat a new electrical switch that turns on and off with a key code. By punching in. Numbers this could be safe for users to put a switch in the open to turn on and off auto turrets without worrying about Enemies turning it off.