i connected the yaw sensor to the toggle switch...everything works fine but, when i close the cap the yaw sensor turns off and when i open the cap the yaw sensor turns off

it should be the opposite way but i dont know how to do it....anyone has an idea?