InoDrive / IO / set_output


InoDrive.IO.set_output(self, target=None, state=None)

Control the Voltage State of a Specific Output.

Arguments:

self (Object): Reference to IO Instance.
target (Integer or String): Module’s Output Range (0 to 2) or 'all'.
state (Boolean): True: Set Output to High; False: Set Output to Low.

Returns: Boolean – True or None on successfully setting the Output.

import CkInoDriveAPI

# Instantiate InoDrive Object and Connect by Name
Drive = CkInoDriveAPI.InoDrive(target='Name', autoConnect=True)

# Take Control of InoDrive to Override Output State
result = Drive.SysControl.take_control(True)

if result:
    # Set All Output States to High
    response = Drive.IO.set_output('all', True)
    # Set Output 1 State to Low
    response = Drive.IO.set_output(1, False)
    # Get All Output States
    # Expected Result – Output 0: High, Output 1: Low, Output 2: High
    outputs = [0, 1, 2]
    for item in outputs:
        state = Drive.IO.get_output(item)
        if state == 0:
            print(f"Output {item} is low.")
        else:
            print(f"Output {item} is high.")