Hi Processing Forum,
I am in the process of hacking a rotary phone, using Arduino and Processing to convert the phone into a recording and playback device. It is a really interesting project and I have made some progress, but I got stuck on a string from the serial port. My code is long, so I will share my public gist here: https://gist.github.com/lizzybrooks/b88531b906860d4fc4af.
Here is the function that seems to be giving me trouble:
void readNumbers(){
if ( myPort.available() > 0)
{
// get the value from the serial port
do{
val = myPort.readStringUntil('\n'); // read it and store it in val
} while (val == null);
// print every value received to the console so we know what we got
// println(val);
// println(val.length());
if (val.equals("6\r\n")){
println("hooray. you work. let's play a different audio file");
// anything else and its input from the phone
// so do whatever you want if you receive input from the phone here...
}
}
If you have any ideas or can help me with syntax, I would so much appreciate it. I am a beginner coder working on a complicated project, but I am eager to learn.
Thanks so much!
Lizzy