user28066: We have been working on this "disaster bot" code for days and hours. AFter all of our hard work, Arduino gives us this error code: expected primary-expression before void. Please please please assist we are so desperate to get this to work. Here is our code below. Please. 
// HEARTBEAT SENSOR (displays heart rate on LCD screen)
int sensorPin = A0; // This is the analog sensor pin the backwards S pin is connected to
                           // you can use any of the analog pins, but would need to change this to match
double alpha = 0.75; // This code uses a rather cool way of averaging the values, using 75% of the 
                               // average of the previous values and 25% of the current value.
int period = 20; // This is how long the code delays in milliseconds between readings (20 mSec)
int in = 8;
int Reset=6;
int start=7;
int count=0,i=0,k=0,rate=0;

// LCD SCREEN
#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// BIG SOUND SENSOR
int soundDetectedPin = 10;
int soundDetectedVal = HIGH;
boolean bAlarm = false;

unsigned long lastSoundDetectTime;

int soundAlarmTime = 500;

// PUSH BUTTON AND BUZZER
int buzzer = 3;
int ledPin = 13;
int inPin = 7;
int val = 0;

#define sing

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

#define melodyPin 3
//Hotline Bling Melody
int hotlineb_melody[] = {
  0, NOTE_D5, NOTE_D5, NOTE_D5,
  NOTE_F5, NOTE_E5, NOTE_D5, NOTE_C5,
  NOTE_E5, NOTE_C5, 0,  NOTE_F5,
  NOTE_E5, NOTE_D5, NOTE_C5, NOTE_E5,

  NOTE_C5, NOTE_A4, NOTE_F5, NOTE_E5,
  NOTE_D5, NOTE_C5, NOTE_E5, NOTE_C5,
  0, NOTE_F5, NOTE_E5, NOTE_D5,
  NOTE_C5, NOTE_E5, NOTE_C5, NOTE_A4,

  NOTE_F5, NOTE_C6, NOTE_C6,
  NOTE_C6, NOTE_A5, NOTE_C6, NOTE_C6,
  NOTE_D6, 0, NOTE_F5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,

  NOTE_A5, 0, NOTE_C6, NOTE_C6,
  NOTE_C6, NOTE_A5, NOTE_C6, NOTE_C6,
  NOTE_D6, 0, NOTE_F5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,

  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_D6, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,

  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_A5, NOTE_A5, NOTE_A5, NOTE_A5,
  NOTE_AS5, NOTE_A5, NOTE_G5, NOTE_F5,
  NOTE_G5, NOTE_G5, NOTE_A5, NOTE_A5,

  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_F5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,

  NOTE_A5, NOTE_D6, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_A5, NOTE_A5, NOTE_A5, NOTE_A5,

  NOTE_AS5, NOTE_A5, NOTE_G5, NOTE_F5,
  NOTE_G5, NOTE_G5, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_G5
};

//HotlineBLING tempo
  int hotlineb_tempo[] = {
  12, 12, 12, 12,
  12, 12, 12, 12,
  6, 2, 3, 12,
  12, 12, 12, 3,

  3, 3, 12, 12,
  12, 12, 6, 2,
  3, 12, 12, 12,
  12, 3, 3, 4,

  12, 12, 12,
  12, 12, 12, 12,
  2, 3, 12, 12,
  12, 12, 12, 12,

  2, 3, 12, 12,
  12, 12, 12, 12,
  3, 3, 12, 12,
  12, 12, 12, 12,

  2, 12, 12, 12,
  12, 12, 12, 12,
  12, 1.5, 12, 12,
  12, 12, 12, 12,

  12, 12, 6, 2,
  12, 12, 12, 12,
  12, 12, 12, 12,
  6, 2, 12, 12,

  12, 12, 12, 12,
  12, 12, 6, 2.4,
  12, 12, 12, 12,
  12, 12, 12, 12,

  12, 1.5, 12, 12,
  12, 12, 12, 12,
  12, 12, 6, 2,
  12, 12, 12, 12,

  12, 12, 12, 12,
  6, 2, 12, 12,
  12, 12, 12, 12,
  12, 12, 8, 24, 2
};

void setup() {


{
  //lcd.createChar(1, heart);
  lcd.begin(16,2);

  lcd.print("Heart Beat");
  lcd.write(1);
  lcd.setCursor(0,1);
  lcd.print("Monitering");
  pinMode(in, INPUT);
  pinMode(Reset, INPUT);
  pinMode(start, INPUT);
  digitalWrite(Reset, HIGH);
  digitalWrite(start, HIGH);
  delay(1000);

  lcd.begin(16,2);
  lcd.print("need to talk?");
  delay(1000);

  lcd.begin(16,2);
  lcd.print("not yet satisfied with care?");
  delay(1000);
}
// This code runs on startup, it sets ledPin to output so it can blink the LED that is built into the
// Arduino (but then never does), and sets the serial port up for fast 115,200 baud communication
// of the values (make sure you change your serial monitor to match).


  Serial.begin (115200); // the baud rate of the serial data
  {
    Serial.begin(115200);
    pinMode (soundDetectedPin, INPUT);
  }
  //PUSH BUTTON AND BUZZER
  {
    pinMode(buzzer, OUTPUT);
    pinMode(13, OUTPUT);
    pinMode(inPin, INPUT);
    }
}

void loop() {
  // HEARTBEAT SENSOR
    static double oldValue = 0; // used for averaging.
    static double oldChange = 0; // not currently used
    int rawValue = analogRead (sensorPin); // This reads in the value from the analog pin.
                                                              // this is a 10 bit number, and will be between 0 and 1023
                                                              // If this value doesn't change, you've connected up
                                                              // something wrong


  unsigned long time2,time1;
  unsigned long time;

    double value = alpha * oldValue + (1 - alpha) * rawValue; // Calculate an average using 75% of the
                                                                                         // previous value and 25% of the new 

    Serial.print (rawValue); // Send out serially the value read in
    Serial.print (",");          // Send a comma
    Serial.println (value);   // Send out the average value and a new line
    oldValue = value;        // Save the average for next iteration
    delay (period);            // Wait 20 mSec

  if((digitalRead(start)))
  {
    k=0;
    lcd.clear();
    lcd.print("Please wait.......");
    while(k<5)
    {
     if(digitalRead(in))
     {
      if(k==0)
      time1=millis();
      k++;
      while(digitalRead(in));
     }
    }
      time2=millis();
      rate=time2-time1;
      rate=rate/5;
      rate=60000/rate;
      lcd.clear();
      lcd.print("Heart Beat Rate:");
      lcd.setCursor(0,1);
      lcd.print(rate);
      lcd.print(" ");
      lcd.write(1);      
      k=0;
      rate=0;
    }

  if(!digitalRead(Reset))
  {

      rate=0;
      lcd.clear();
      lcd.print("Heart Beat Rate:");
      lcd.setCursor(0,1);
      lcd.write(1);
      lcd.print(rate);
      k=0;
  }
  // LCD SCREEN (helpful hotlines message)
  {
    lcd.setCursor(0,1);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("1-800-273-8255");
    delay(1000);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("1-877-726-4727");
    delay(1000);
  }
  // BIG SOUND SENSOR
  {
    soundDetectedVal = digitalRead(soundDetectedPin);

    if (soundDetectedVal == LOW)
    {
      lastSoundDetectTime = millis();
      if (!bAlarm){
        Serial.println("you're doing great :)");
        bAlarm = true;
      }
    }
    else
    {
      if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm) {
        Serial.println("keep breathing");
        bAlarm = false;
      }
    }
  }
  // LCD SCREEN (are feeling better/listen to these sick tunes buddy message)
  {
    lcd.setCursor(0,1);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("if still need comfort");
    delay(500);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("hold button");
    delay(1000);
    }
    //PUSH BUTTON AND BUZZER
    {
      val = digitalRead(inPin);
      if (val == HIGH) {
        digitalWrite(buzzer, LOW);
      } else {
        digitalWrite(buzzer, HIGH);
      }
      }
// BUZZER
{{
  sing(1);
  sing(1);
  sing(2);
  }
  int song = 0;
   void sing(int s) {
    song = s;
    if (song == 1) {
      Serial.println("recognize this?");
      int size = sizeof(hotlineb_melody) / sizeof(int);
      for (int thisNote = 0; thisNote < size; thisNote++) {
        int noteDuration = 1000 / hotlineb_tempo[thisNote];

        buzz(melodyPin, hotlineb_melody[thisNote], noteDuration);

        int pauseBetweenNotes = noteDuration * 1.30;
        delay(pauseBetweenNotes);

        buzz(melodyPin, 0, noteDuration);
      }
    }
  }
  {
    void buzz(int targetPin, long frequency, long length) {
      digitalWrite(13, HIGH);
      long delayValue = 1000000 / frequency / 2;
      long numCycles = frequency * length / 1000;
      for (long i - 0; i < numCycles; i++) {
        digitalWrite(targetPin, HIGH);
        delayMicroseconds(delayValue);
        digitalWrite(targetPin, LOW);
        delayMicroseconds(delayValue);
      }
      digitalWrite(13, LOW);
          }
        }
      }
    }
  }
}


user7508: Here are the problems I found while trying to make your code compile:
Opening and closing braces should match
Trying to autoformat your code gave me the error:

Auto Format Canceled: Too many right curly braces.

I had to remove the last two braces for Auto Format to succeed.
Functions cannot be nested
You should move the declarations of sing() and buzz() out of
loop(). You can call them from loop() though.
Other random errors

#define sing is defining sing as an empty string, and you cannot
give a function an empty name
the variable song should be either global or local to sing(), not
local to loop()
to declare and initialize a variable to zero you should write
int i = 0, not int i - 0
soundAlarmTime should be unsigned
oldChange and time should be removed (they are not used)


28066: <p>We have been working on this "disaster bot" code for days and hours. AFter all of our hard work, Arduino gives us this error code: expected primary-expression before void. Please please please assist we are so desperate to get this to work. Here is our code below. Please. </p>

<pre><code>// HEARTBEAT SENSOR (displays heart rate on LCD screen)
int sensorPin = A0; // This is the analog sensor pin the backwards S pin is connected to
                           // you can use any of the analog pins, but would need to change this to match
double alpha = 0.75; // This code uses a rather cool way of averaging the values, using 75% of the 
                               // average of the previous values and 25% of the current value.
int period = 20; // This is how long the code delays in milliseconds between readings (20 mSec)
int in = 8;
int Reset=6;
int start=7;
int count=0,i=0,k=0,rate=0;

// LCD SCREEN
#include&lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// BIG SOUND SENSOR
int soundDetectedPin = 10;
int soundDetectedVal = HIGH;
boolean bAlarm = false;

unsigned long lastSoundDetectTime;

int soundAlarmTime = 500;

// PUSH BUTTON AND BUZZER
int buzzer = 3;
int ledPin = 13;
int inPin = 7;
int val = 0;

#define sing

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

#define melodyPin 3
//Hotline Bling Melody
int hotlineb_melody[] = {
  0, NOTE_D5, NOTE_D5, NOTE_D5,
  NOTE_F5, NOTE_E5, NOTE_D5, NOTE_C5,
  NOTE_E5, NOTE_C5, 0,  NOTE_F5,
  NOTE_E5, NOTE_D5, NOTE_C5, NOTE_E5,

  NOTE_C5, NOTE_A4, NOTE_F5, NOTE_E5,
  NOTE_D5, NOTE_C5, NOTE_E5, NOTE_C5,
  0, NOTE_F5, NOTE_E5, NOTE_D5,
  NOTE_C5, NOTE_E5, NOTE_C5, NOTE_A4,

  NOTE_F5, NOTE_C6, NOTE_C6,
  NOTE_C6, NOTE_A5, NOTE_C6, NOTE_C6,
  NOTE_D6, 0, NOTE_F5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,

  NOTE_A5, 0, NOTE_C6, NOTE_C6,
  NOTE_C6, NOTE_A5, NOTE_C6, NOTE_C6,
  NOTE_D6, 0, NOTE_F5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,

  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_D6, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,

  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_A5, NOTE_A5, NOTE_A5, NOTE_A5,
  NOTE_AS5, NOTE_A5, NOTE_G5, NOTE_F5,
  NOTE_G5, NOTE_G5, NOTE_A5, NOTE_A5,

  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_F5, NOTE_C6, NOTE_A5, NOTE_C6,
  NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6,

  NOTE_A5, NOTE_D6, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_G5,
  NOTE_A5, NOTE_A5, NOTE_A5, NOTE_A5,

  NOTE_AS5, NOTE_A5, NOTE_G5, NOTE_F5,
  NOTE_G5, NOTE_G5, NOTE_A5, NOTE_A5,
  NOTE_A5, NOTE_A5, NOTE_AS5, NOTE_A5,
  NOTE_G5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_G5
};

//HotlineBLING tempo
  int hotlineb_tempo[] = {
  12, 12, 12, 12,
  12, 12, 12, 12,
  6, 2, 3, 12,
  12, 12, 12, 3,

  3, 3, 12, 12,
  12, 12, 6, 2,
  3, 12, 12, 12,
  12, 3, 3, 4,

  12, 12, 12,
  12, 12, 12, 12,
  2, 3, 12, 12,
  12, 12, 12, 12,

  2, 3, 12, 12,
  12, 12, 12, 12,
  3, 3, 12, 12,
  12, 12, 12, 12,

  2, 12, 12, 12,
  12, 12, 12, 12,
  12, 1.5, 12, 12,
  12, 12, 12, 12,

  12, 12, 6, 2,
  12, 12, 12, 12,
  12, 12, 12, 12,
  6, 2, 12, 12,

  12, 12, 12, 12,
  12, 12, 6, 2.4,
  12, 12, 12, 12,
  12, 12, 12, 12,

  12, 1.5, 12, 12,
  12, 12, 12, 12,
  12, 12, 6, 2,
  12, 12, 12, 12,

  12, 12, 12, 12,
  6, 2, 12, 12,
  12, 12, 12, 12,
  12, 12, 8, 24, 2
};

void setup() {


{
  //lcd.createChar(1, heart);
  lcd.begin(16,2);

  lcd.print("Heart Beat");
  lcd.write(1);
  lcd.setCursor(0,1);
  lcd.print("Monitering");
  pinMode(in, INPUT);
  pinMode(Reset, INPUT);
  pinMode(start, INPUT);
  digitalWrite(Reset, HIGH);
  digitalWrite(start, HIGH);
  delay(1000);

  lcd.begin(16,2);
  lcd.print("need to talk?");
  delay(1000);

  lcd.begin(16,2);
  lcd.print("not yet satisfied with care?");
  delay(1000);
}
// This code runs on startup, it sets ledPin to output so it can blink the LED that is built into the
// Arduino (but then never does), and sets the serial port up for fast 115,200 baud communication
// of the values (make sure you change your serial monitor to match).


  Serial.begin (115200); // the baud rate of the serial data
  {
    Serial.begin(115200);
    pinMode (soundDetectedPin, INPUT);
  }
  //PUSH BUTTON AND BUZZER
  {
    pinMode(buzzer, OUTPUT);
    pinMode(13, OUTPUT);
    pinMode(inPin, INPUT);
    }
}

void loop() {
  // HEARTBEAT SENSOR
    static double oldValue = 0; // used for averaging.
    static double oldChange = 0; // not currently used
    int rawValue = analogRead (sensorPin); // This reads in the value from the analog pin.
                                                              // this is a 10 bit number, and will be between 0 and 1023
                                                              // If this value doesn't change, you've connected up
                                                              // something wrong


  unsigned long time2,time1;
  unsigned long time;

    double value = alpha * oldValue + (1 - alpha) * rawValue; // Calculate an average using 75% of the
                                                                                         // previous value and 25% of the new 

    Serial.print (rawValue); // Send out serially the value read in
    Serial.print (",");          // Send a comma
    Serial.println (value);   // Send out the average value and a new line
    oldValue = value;        // Save the average for next iteration
    delay (period);            // Wait 20 mSec

  if((digitalRead(start)))
  {
    k=0;
    lcd.clear();
    lcd.print("Please wait.......");
    while(k&lt;5)
    {
     if(digitalRead(in))
     {
      if(k==0)
      time1=millis();
      k++;
      while(digitalRead(in));
     }
    }
      time2=millis();
      rate=time2-time1;
      rate=rate/5;
      rate=60000/rate;
      lcd.clear();
      lcd.print("Heart Beat Rate:");
      lcd.setCursor(0,1);
      lcd.print(rate);
      lcd.print(" ");
      lcd.write(1);      
      k=0;
      rate=0;
    }

  if(!digitalRead(Reset))
  {

      rate=0;
      lcd.clear();
      lcd.print("Heart Beat Rate:");
      lcd.setCursor(0,1);
      lcd.write(1);
      lcd.print(rate);
      k=0;
  }
  // LCD SCREEN (helpful hotlines message)
  {
    lcd.setCursor(0,1);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("1-800-273-8255");
    delay(1000);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("1-877-726-4727");
    delay(1000);
  }
  // BIG SOUND SENSOR
  {
    soundDetectedVal = digitalRead(soundDetectedPin);

    if (soundDetectedVal == LOW)
    {
      lastSoundDetectTime = millis();
      if (!bAlarm){
        Serial.println("you're doing great :)");
        bAlarm = true;
      }
    }
    else
    {
      if( (millis()-lastSoundDetectTime) &gt; soundAlarmTime &amp;&amp; bAlarm) {
        Serial.println("keep breathing");
        bAlarm = false;
      }
    }
  }
  // LCD SCREEN (are feeling better/listen to these sick tunes buddy message)
  {
    lcd.setCursor(0,1);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("if still need comfort");
    delay(500);
    lcd.clear();
    lcd.begin(16,2);
    lcd.print("hold button");
    delay(1000);
    }
    //PUSH BUTTON AND BUZZER
    {
      val = digitalRead(inPin);
      if (val == HIGH) {
        digitalWrite(buzzer, LOW);
      } else {
        digitalWrite(buzzer, HIGH);
      }
      }
// BUZZER
{{
  sing(1);
  sing(1);
  sing(2);
  }
  int song = 0;
   void sing(int s) {
    song = s;
    if (song == 1) {
      Serial.println("recognize this?");
      int size = sizeof(hotlineb_melody) / sizeof(int);
      for (int thisNote = 0; thisNote &lt; size; thisNote++) {
        int noteDuration = 1000 / hotlineb_tempo[thisNote];

        buzz(melodyPin, hotlineb_melody[thisNote], noteDuration);

        int pauseBetweenNotes = noteDuration * 1.30;
        delay(pauseBetweenNotes);

        buzz(melodyPin, 0, noteDuration);
      }
    }
  }
  {
    void buzz(int targetPin, long frequency, long length) {
      digitalWrite(13, HIGH);
      long delayValue = 1000000 / frequency / 2;
      long numCycles = frequency * length / 1000;
      for (long i - 0; i &lt; numCycles; i++) {
        digitalWrite(targetPin, HIGH);
        delayMicroseconds(delayValue);
        digitalWrite(targetPin, LOW);
        delayMicroseconds(delayValue);
      }
      digitalWrite(13, LOW);
          }
        }
      }
    }
  }
}
</code></pre>
 7508: <p>Here are the problems I found while trying to make your code compile:</p>

<h2>Opening and closing braces should match</h2>

<p>Trying to autoformat your code gave me the error:</p>

<blockquote>
  <p>Auto Format Canceled: Too many right curly braces.</p>
</blockquote>

<p>I had to remove the last two braces for Auto Format to succeed.</p>

<h2>Functions cannot be nested</h2>

<p>You should move the declarations of <code>sing()</code> and <code>buzz()</code> out of
<code>loop()</code>. You can <strong>call</strong> them from <code>loop()</code> though.</p>

<h2>Other random errors</h2>

<ul>
<li><p><code>#define sing</code> is defining <code>sing</code> as an empty string, and you cannot
give a function an empty name</p></li>
<li><p>the variable <code>song</code> should be either global or local to <code>sing()</code>, not
local to <code>loop()</code></p></li>
<li><p>to declare and initialize a variable to zero you should write
<code>int i = 0</code>, not <code>int i - 0</code></p></li>
<li><p><code>soundAlarmTime</code> should be unsigned</p></li>
<li><p><code>oldChange</code> and <code>time</code> should be removed (they are not used)</p></li>
</ul>
