def get_serial():
    """
    Detect if a micro:bit is connected and return a serial object to talk to
    it.
    """
    port, serial_number = find_microbit()
    if port is None:
        raise IOError('Could not find micro:bit.')
    return Serial(port, SERIAL_BAUD_RATE, timeout=1, parity='N')
Detect if a micro:bit is connected and return a serial object to talk to
    it.