I wrote a library for robotMotion where I have commands to move forward, backward, turn left and right. I also had to clear the modes whenever I wanted to change them. This is because bit set does not clear any previous bit, so once I went into reset/set mode, 111, I could never get out of it until I cleared the bits. I did this by &= ~ every mode every time I want to change the modes.