Hello everyone!
So I'm new to arduino and my first bigger project is a midi controller with an ultrasonic sensor.
I wrote the program from the ground up and using serial.println I tested the ultrasonic sensor and everything worked fine.
But once I added the serial.write command to send midi data over USB to my computer the strange symbols and characters started showing up in the Serial Monitor. I'm at a complete loss, hours of googling didn't give me any solutions for this and I have no idea why this is happening. Before this project I already built a simple Midi Controller using a potentiometer and everything worked fine.
Here is my code:
int controlChange = 176; // MIDI Kanal 1
int controllerNummer = 21;
int controllerWert = 0;
int triggerPin = 3;
int echoPin = 2;
long messung = 0;
long ergebnis = 0;void setup() {
Serial.begin(9600);
pinMode(triggerPin, OUTPUT);
pinMode(echoPin, INPUT);
}void loop() {
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);messung = pulseIn(echoPin, HIGH);
ergebnis = (messung/2)/29;
if (ergebnis<100){
controllerWert = map(ergebnis,0,50,0,127);
constrain(controllerWert,0,127);Serial.write(controllerWert); // This is the midi value I am trying to send!
Serial.println(controllerWert);
}
}
I also attached a screenshot of my Serial Monitor giving me those weird values I was talking about.
I really hope someone can help me with this.