def define_as_input(self, pin, pullup=False):
        """Set the input or output mode for a specified pin.  Mode should be
        either GPIO.OUT or GPIO.IN.
        """
        self._validate_channel(pin)
        # Set bit to 1 for input or 0 for output.
        self.iodir[int(pin/8)] |= 1 << (int(pin%8))
        self._write_iodir()
        self.pullup(pin, pullup)