// get rid of any whitespace - sometimes the serial buffer can have blanks etc.. in the string
bufferString = trim(bufferString);
// convert the value to an int - we're only sending numbers over the serial port so parsing it to an int shouldn't ever be an issue.
float inByte = float(bufferString);
int pulse = int(bufferString); // declare a variable to hold our value.
println(pulse); // for debug print the value so we can check it.
// remember that our pulse is in CM so if its less than 5cm then do this etc... else do this... else do this.. for as many sound samples
if ( pulse < 5 ) {
GSharp.trigger();
delay(25);
}
else if ( pulse < 8 ) {
A.trigger();
delay(25);
}
else if ( pulse < 11 ) {
Bb.trigger();
delay(25);
}
else if ( pulse < 14 ) {
B.trigger();
delay(25);
}
else if ( pulse < 17 ) {
C.trigger();
delay(25);
}
else if ( pulse < 20 ) {
CSharp.trigger();
delay(25);
}
else if ( pulse < 23 ) {
D.trigger();
delay(25);
}
else if ( pulse < 26 ) {
Eb.trigger();
delay(25);
}
else if ( pulse < 29 ) {
E.trigger();
delay(25);
}
else if ( pulse < 32 ) {
F.trigger();
delay(25);
}
else if ( pulse < 35 ) {
FSharp.trigger();
delay(25);
}
else if ( pulse < 38 ) {
G.trigger();
delay(25);
}
else if ( pulse > 50 ) {
// if the distance is greater than 50cm then play nothing
}
} // end if there's a value in the serial bufferstring
} // end void serialevent()
I've downloaded the music files, I've changed the name and I've put them into sketch folder, then I've change the COM port by [0] (above, in red). After that, I'm getting the same error.
What can I do?
I was thinking about using another minim fuction (such as AudioPlayer), but I have no idea how to do that (my programing knowledge is too limited).