added toggle function to the solenoid

changed the way the solenoid fired in the code