from pycaw.pycaw import AudioUtilities from pprint import pprint import serial import serial.tools.list_ports import time def main(): print ("Starting Arduino Mixer...\n") # Get audio sessions sessions = AudioUtilities.GetAllSessions() print (str(len(sessions)) + " audio sessions found:") for session in sessions: volume = session.SimpleAudioVolume print (" " + str(session.Process)) # Init serial connection ports = serial.tools.list_ports.comports() if len(ports) == 0: print("\nNo Serial ports Available") exit() else: print ("\nSerial ports Available:") for port, desc, hwid in sorted(ports): print(" {}: {} [{}]".format(port, desc, hwid)) board = serial.Serial() board.baudrate = 115200 board.port = input("\nSelect COM port: ") board.open() print ("Waiting for arduino...") time.sleep(5) board.write("".encode("utf-8")) board.write("".encode("utf-8")) board.write("".encode("utf-8")) board.write("".encode("utf-8")) if __name__ == "__main__": main()