from binhoHostAdapter import binhoUtilities
from binhoHostAdapter import binhoHostAdapter
utilities = binhoUtilities.binhoUtilities()
devices = utilities.listAvailableDevices()
print('Binho Host Adapters Found On The Following Ports:')
# Make sure at least one binho device was found before proceeding
print('No Binho Host Adapter found...Quitting script')
# Target the port of the first device in the list
print('Connecting to host adapter on ' + targetPort)
# Connect to the binho device on the target port
binho = binhoHostAdapter.binhoHostAdapter(targetPort)
# Set the LED color to GREEN
binho.setLEDColor('GREEN')
print('Set LED to Green')
# Set the operation mode to IO
binho.setOperationMode(0, 'IO')
binho.setIOpinMode(0, 'PWM')
# Set IO0 PWM Frequency to 75kHz
binho.setIOpinPWMFreq(0, 75000)
# Set IO0 PWM duty cycle to 512/1024
binho.setIOpinValue(0, 512)
print('IO0 set to PWM with 50% duty cycle / 75kHz frequency')
# Close the connection to the device before exiting
print('Connection closed!')