My program reads the input and plays the appropriate note for 500 milliseconds. If I type in 'a', tone(8, 440, 500) will be called. I now want to add different note lengths so that in the future, I can play songs by sending code to Arduino. I was thinking that if 'a' is typed in, the program checks the next character. If it's a 1, it's a whole note. If it's a 2, it's a half note. My code doesn't work. What is wrong with it?
Turned out the arduino couldn't read the values fast enough. Adding while (!Serial.available()){} before the second read solved the problem. Thank you for the help
First, take a careful read of the post that Robin suggested. Second, with your code in the source window in the IDE, simultaneously press the Ctrl and T keys (Ctrl-T) and see what happens. It will make life easier on those who have to read your code. Third, what happens if the user enters an 'A' instead of 'a'? Fourth, read up on the toupper() and tolower() macros and see if either of those might be of help.