/** * Toggles the specified bitPort bit and returns the new state. * * @param bitPort a bit that controls an LED. */ private static boolean toggle(BitPort bitPort) { if (bitPort.readLatch() == 0) { // If it's 0, set the bit to turn the LED off and return false. bitPort.set(); return false; } else { // If it's 1, clear the bit to turn the LED on and return true. bitPort.clear(); return true; } } // end toggle Listing 3. The servlet’s toggle() method toggles the LED at the named port bit.