# tb6612_demo.py
# Top-level script to demonstrate use of the tb6612 module.

# Enable access to the sleep function.
import time

# Load the code from tb6612.py and make all attributes available.
import tb6612

# Create a default instance of the driver class.
driver = tb6612.TB6612()

# Enter an infinite loop driving the two outputs through various directions and speeds.
while True:

    print("Start")
    driver.write(0,  1.0)
    driver.write(1,  0.0)
    time.sleep(1.0)

    print("next")
    driver.write(0,  0.5)
    driver.write(1, -0.5)
    time.sleep(1.0)

    print("next")
    driver.write(0, -0.5)
    driver.write(1,  0.5)
    time.sleep(1.0)

    print("next")
    driver.write(0, -1.0)
    driver.write(1,  1.0)
    time.sleep(1.0)

    print("next")
    driver.write(0,  0.0)
    driver.write(1,  0.0)
    time.sleep(1.0)
