+Projjal Gupta Hi, Projjal, The arduino has not much code, the important part is this. The part of interpretation of midi and send it through serial is in C#. I need to search that code in my backups. But in the arduino side, It's just receiving a string of the binary output of the sumatory of all the keys of the piano. Because the arduino doesn't have 88 outputs. LOL! XD hahaha, I feel embarrased with this code. I search many ways to make it sync with music tempo. And this was the closest way I get with code. Even using the simplest cicle to go through the inputString, could generate a delay. If you find a better way, I would love to see it. void loop() { if (stringComplete) { // clear the string: Serial.println("desde el usb:"); Serial.println(inputString); /*ECHO the value that was read, back to the serial port. */ analogWrite(0, inputString[0] == '1' ? 255:0); analogWrite(1, inputString[1] == '1' ? 255:0); analogWrite(2, inputString[2] == '1' ? 255:0); analogWrite(3, inputString[3] == '1' ? 255:0); analogWrite(4, inputString[4] == '1' ? 255:0); analogWrite(5, inputString[5] == '1' ? 255:0); analogWrite(6, inputString[6] == '1' ? 255:0); analogWrite(7, inputString[7] == '1' ? 255:0); analogWrite(8, inputString[8] == '1' ? 255:0); analogWrite(9, inputString[9] == '1' ? 255:0); analogWrite(10, inputString[10] == '1' ? 255:0); analogWrite(11, inputString[11] == '1' ? 255:0); analogWrite(12, inputString[12] == '1' ? 255:0); analogWrite(13, inputString[13] == '1' ? 255:0); delay(30); inputString = ""; stringComplete = false; } } void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (inChar == ' ') { stringComplete = true; //catch the enter to finish the string } } }
Un genio, te felicito, esta muy bien hecho
how did you take the midi notes input value? could you give me an insight to your arduino code?
+Projjal Gupta Hi, Projjal,
The arduino has not much code, the important part is this. The part of interpretation of midi and send it through serial is in C#. I need to search that code in my backups.
But in the arduino side, It's just receiving a string of the binary output of the sumatory of all the keys of the piano.
Because the arduino doesn't have 88 outputs. LOL! XD
hahaha, I feel embarrased with this code. I search many ways to make it sync with music tempo. And this was the closest way I get with code. Even using the simplest cicle to go through the inputString, could generate a delay.
If you find a better way, I would love to see it.
void loop() {
if (stringComplete) {
// clear the string:
Serial.println("desde el usb:");
Serial.println(inputString);
/*ECHO the value that was read, back to the serial port. */
analogWrite(0, inputString[0] == '1' ? 255:0);
analogWrite(1, inputString[1] == '1' ? 255:0);
analogWrite(2, inputString[2] == '1' ? 255:0);
analogWrite(3, inputString[3] == '1' ? 255:0);
analogWrite(4, inputString[4] == '1' ? 255:0);
analogWrite(5, inputString[5] == '1' ? 255:0);
analogWrite(6, inputString[6] == '1' ? 255:0);
analogWrite(7, inputString[7] == '1' ? 255:0);
analogWrite(8, inputString[8] == '1' ? 255:0);
analogWrite(9, inputString[9] == '1' ? 255:0);
analogWrite(10, inputString[10] == '1' ? 255:0);
analogWrite(11, inputString[11] == '1' ? 255:0);
analogWrite(12, inputString[12] == '1' ? 255:0);
analogWrite(13, inputString[13] == '1' ? 255:0);
delay(30);
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '
') {
stringComplete = true; //catch the enter to finish the string
}
}
}
+jcsotom Thanks a lot, I will take a look into this. if I find ways to tweak this code then I will certainly share it with you :D