Help! I'm just a beginner, can someone help me take a look? Thank you!

#include<DHT.h>
#include <Wire.h>
#include<BH1750.h>
#include<SoftwareSerial.h>
#include<U8glib.h>
#include <IRremote.hpp>
U8GLIB_SSD1306_128X64 u8g(52, 51, 11, 10, 9);
BH1750 ls;
DHT dht(7,DHT11);
#define OLED_RESET 4  
int page=1;
void setup() {
  // put your setup code here, to run once:
  pinMode(2,INPUT);pinMode(3,INPUT);pinMode(5,INPUT);pinMode(6,INPUT);
  pinMode(7,INPUT);pinMode(8,INPUT);pinMode(13,OUTPUT);
  Serial.begin(115200);Wire.begin();
  Serial3.begin(38400);
  IrReceiver.begin(4, ENABLE_LED_FEEDBACK);
  dht.begin();ls.begin();
  digitalWrite(13,HIGH);
}
void playsound(int f,int d){
  tone(13,f);
  delay(d);
  noTone(13);
  digitalWrite(13,HIGH);
}
void buttonc(){
  int nowmess=0;
  if(digitalRead(3)==HIGH){
    Serial.println("forward");
    page++;
    playsound(392,50);
    while(digitalRead(3)==HIGH)delay(100);
    nowmess=2;
    delay(100);
  }else if(IrReceiver.decode()){
    if(IrReceiver.decodedIRData.command==0xEA41){
      page--;
      playsound(392,50);
    }else if(IrReceiver.decodedIRData.command==0xCA41){
      page++;
      playsound(392,50);
    }
    while(IrReceiver.decode()){
      IrReceiver.resume();
      delay(100);
    }
    IrReceiver.resume();
  }
  if(page<=0)page=3;
  if(page>3)page=1;
}
float vol,h,t;
int mode=1,noid,mot,light,P;
void getppm(){
  vol = getVoltage(1);//MQ135->A1
  Serial.print(vol);Serial.print(" ");
}
float getVoltage(int pin){
  return (analogRead(pin)*0.004882814);
}
void getnoise(){
  noid=analogRead(2);
  Serial.print(noid);Serial.print(" ");
}
void getht(){
  h = dht.readHumidity();
  t = dht.readTemperature();
  Serial.print(h);Serial.print(" ");Serial.print(t);Serial.print(" ");
}
void getman(){
  mot=digitalRead(8);
  Serial.print(mot);Serial.print(" ");
}
void getli(){
  light=ls.readLightLevel();
  Serial.println(light);
}
int olda=1,oldb=1;
void turnsol(){
  int na=digitalRead(5),nb=digitalRead(6);
  int res=(na!=olda||nb!=oldb)&&(olda==1&&na==0)?oldb*2-1:0;
  olda=na;oldb=nb;
  mode+=res;
  if(mode<1)mode=3;
  if(mode>3)mode=1;
}
void drawpage1(){
  u8g.setFont(u8g_font_unifont);
  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_5x7r);
  u8g.drawStr(10, 10, "PPM:");u8g.setPrintPos(90,10);u8g.print(vol);
  u8g.drawStr(10, 20, "volume:");u8g.setPrintPos(90,20);u8g.print(noid);
  u8g.drawStr(10, 30, "humidity:");u8g.setPrintPos(90,30);u8g.print(h);
  u8g.drawStr(10, 40, "temperature:");u8g.setPrintPos(90,40);u8g.print(t);
  u8g.drawStr(10, 50, "human infrared:");u8g.setPrintPos(90,50);u8g.print(mot);
  u8g.drawStr(10, 60, "brightness:");u8g.setPrintPos(90,60);u8g.print(light);
}
void drawpage2(){
  u8g.setFont(u8g_font_unifont);
  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_5x7r);
  u8g.drawStr(10, 10, "bluetooth:");
  if(digitalRead(12)==HIGH)u8g.drawStr(60, 10, "connected");
  else u8g.drawStr(60, 10, "disconnected");
}
void drawpage3(){
  u8g.setFont(u8g_font_unifont);
  u8g.setColorIndex(1);
  u8g.setFont(u8g_font_6x13r);
  u8g.drawStr(10, 10, "mode:");
  if(mode==1)u8g.drawStr(50, 30, "AUTO");
  if(mode==2)u8g.drawStr(50,30,"REST");
  if(mode==3)u8g.drawStr(50,30,"SPORTS");
}
void loop() {
  // put your main code here, to run repeatedly:
  getppm();
  getnoise();
  getht();
  getman();
  getli();
  buttonc();
  if(page==3)turnsol();
  u8g.firstPage();
  do{
    if(page==1)drawpage1();
    if(page==2)drawpage2();
    if(page==3)drawpage3();
  }while(u8g.nextPage());
  if(page==1||page==2)delay(500);
  else delay(50);
}

I don't know why, but my buzzer (port 13) keeps ringing even though the playsound function hasn't been triggered. Can someone help me take a look? Thank you!

What type of buxxer is it ?

If it is an active buzzer then connecting it to 5V will cause it to buzz at a fixed frequency. No software needed. If it is a passive type then you need software such as the Tone library to make it sound a tone and you can control its frequency

Umm...Perhaps it's an active buzzer.

Leave it connected between pin 13 and GND and run the Blink example sketch. If it buzzes then it is an active buzzer

Yes, it's an active buzzer

oh,i have solved it.thanks!

How?

Did you change the active buzzer to a passive buzzer or change playsound(frq, dur); to digitalWrite(pin, HIGH)? Removed all tone() calls?