
# Python script to enable this USB relay. # Make sure to run the following command once from the Windows command line # before running this script if # the pyserial module is not already installed. # This allows Python to communicate with your COM ports. Port, connect your relay to a USB port on your computer. # Now go to Device Manager in Control Panel. # Look in Device Manager in the "Com ports" section, unplug the relay and plug it back in. # Com The port, which disappears from the list when you unplug it and then reappears when you plug it back in, shows the correct com port number, which you should refer to # at the bottom of this script. the following line might be different!ser=serial.Serial(port='com3',baudrate=9600)ser.close()ser.open()while(1): ser.write(bytes.fromhex("A0 01 01 A2")) print('Circuit closed. Button pressed') sleep(3) ser.write(bytes. fromhex("A0 01 00 A1")) print('Circuit open. Button released ') sleep( 3)ser.close()