Serial monitor causes the ArduinoStudio to freeze.

I am following the projects in the Arduino starter kit.

I am currently on the 7th project which is a keyboard instrument which requires me to read values using a serial monitor.

However whenever I open the serial monitor on Arduino studio it runs for a second, showing values then freezes the entire program entirely, forcing me to close it. Below is the current code I am using.

int notes[] = {262,294,330,349}; // set the frequencies of the notes used
void setup() {
void loop() {
    int keyVal = analogRead(A0); // read the values from the buttons
    Serial.println(keyVal); // print the values
    if(keyVal == 1023){
        tone(8, notes[0]); // play note 0
    else if(keyVal >= 990 && keyVal <= 1010){
        tone(8, notes[1]); // play note 1
    else if(keyVal >=505 && keyVal <= 515){
        tone(8, notes[2]); // play note 2
    else if(keyVal >= 3 && keyVal <= 20){
        tone(8, notes[3]); // play note 3
        noTone(8); // If not value is read play no note

It has happened on all programs that i have tried except one which was I used to test the monitor as shown below.

/* YourDuinoStarter_SerialMonitor_SEND_RCVE
   - Receives characters from Serial Monitor
   - Displays received character as Decimal, Hexadecimal and Character
   - Controls pin 13 LED from Keyboard
 - SEE the comments after "//" on each line below
   - None: Pin 13 built-in LED
 - V1.00 02/11/13
   Questions: */

/*-----( Import needed libraries )-----*/
/*-----( Declare Constants and Pin Numbers )-----*/
#define led 13  // built-in LED
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
int ByteReceived;

void setup()   /****** SETUP: RUNS ONCE ******/
  Serial.println("--- Start Serial Monitor SEND_RCVE ---");
    Serial.println(" Type in Box above, . ");
//--(end setup )---

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
  if (Serial.available() > 0)
    ByteReceived =;
    Serial.print("        ");      
    Serial.print(ByteReceived, HEX);
    Serial.print("       ");     
    if(ByteReceived == '1') // Single Quote! This is a character.
      Serial.print(" LED ON ");
    if(ByteReceived == '0')
      Serial.print(" LED OFF");
    Serial.println();    // End the line

  // END Serial Available

//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

/*********( THE END )***********/

I think the problem is that the codes I have been using are constantly updating whereas the code I tested it with above, only updates once I send a value using the serial monitor.

With previous codes I have inserted a delay of 1-15 milliseconds but still made no difference.

I have the serial monitor set to 9600 baud rate and tried multiple different end of line settings.

Does the Arduino continue to run (playing notes) if you comment out the Serial.println() statement?

The arduino continues to run with or without the Serial.println() and even if the software is frozen, the arduino continues to run as normal. Its just the software that seems to freeze not the board.

Can you explain what you mean by ArduinoStudio? The Arduino IDE can open the Serial Monitor application. Is that what you are using? Or, are you using something else?

Yea I believe it is the Arduino IDE. Downloaded from Its the program I have used to code, upload and monitor(Serial monitor) the arduino.

Dump that crap. Use the Arduino IDE and Serial Monitor from

That worked! Thanks a lot!

I did not know that there was another piece of software. I just downloaded the one from the book.