bus1 = IoPi(newbus, 0x20)

# We will write to the pins 9 to 16 from bus 1 so set port 1 to be outputs
# turn off the pins
bus1.set_port_direction(1, 0x00)
bus1.write_port(1, 0x00)

while True:

    # count to 255 and display the value on pins 9 to 16 in binary format
    for x in range(0, 255):
        time.sleep(0.05)
        bus1.write_port(1, x)

    # turn off all of the pins on bank 1
    bus1.writePort(1, 0x00)

    # now turn on all of the leds in turn by writing to one pin at a time
    bus1.write_pin(9, 1)
    time.sleep(0.1)
    bus1.write_pin(10, 1)
    time.sleep(0.1)
    bus1.write_pin(11, 1)
    time.sleep(0.1)
    bus1.write_pin(12, 1)
    time.sleep(0.1)
    bus1.write_pin(13, 1)
    time.sleep(0.1)
    bus1.write_pin(14, 1)
    time.sleep(0.1)
    bus1.write_pin(15, 1)