0
votes

I want to send a message from python via serial to arduino uno and then from arduino to hairless MIDI to control LMMS software. The problem is that the communication in both cases goes through port COM4. Is it somehow possible to get data from python through a different port?

Python code:

import serial

ser = serial.Serial('COM4', baudrate = 9600, timeout = 1)

def getValues(input):
    if(input == 'y'):
        ser.write(b'g')
    else:
        ser.write(b'h')


while(1):
    userInput = input('Get data point?')
    getValues(userInput)

Arduino code:

char userInput;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if(Serial.available()>0){
    userInput = Serial.read();
    if(userInput == 'g'){
      Serial.write(144);
    }
    else if(userInput == 'h'){
      Serial.write(0);
    }
  }
}
1
so you want to communicate between two pieces of software through an Arduino? Why? What is the purpose of the Arduino here?Piglet
The arduino with connected sensors works as a MIDI controller. The python code will provide an user interface to turn on the MIDI controler and it will analyze how precise the song was playedAdrian P

1 Answers

0
votes

Python and Hairless MIDI cannot communitcate with Arduino over the same COM port simultaneously.

You would have to open and close the connection in each software alternatingly.

I suggest you use a Python MIDI library that replaces the Hairless MIDI functionality.