Arduino metronome isn't working properly

I'm complete beginner. I was trying to do a metronome on Tinkercard. I did some research.
My program should do: Give the beats according to potentiometer(when I turn it bpm should go up or down).
My program does: Gives a beat and 2.5-3 seconds later gives another beat, no difference when I turn the potentiometer.

#include <SPI.h>
#include <Wire.h>
#define BUZZER  10      // buzzer pin
#define MIN_BPM 20      // minimum bpm value
#define MAX_BPM 240     // maximum bpm value
#define POT A0          // pot analog pin

int bpm; 


void setup() {
  
  pinMode(BUZZER, OUTPUT);  
  
}
void loop() {

    bpm = map(analogRead(POT), 0, 1023, MIN_BPM, MAX_BPM);  
    tone(BUZZER, 2500);       
    delay(3000 / bpm);        
    noTone(BUZZER);           
    delay(54000 / bpm);       

}

This is the schematic: imgur.com/a/AIJuxop

How can I make it work properly?

Both outher ends of the pot looks like being connected to GND. One to GND, one to VCC is needed.

Looks like Fritzing has met it's match, TinkerCad. >:(

Try this here. :slight_smile:

#include <SPI.h>
#include <Wire.h>
#define BUZZER  10      // buzzer pin
#define MIN_BPM 20      // minimum bpm value
#define MAX_BPM 240     // maximum bpm value
#define POT A0          // pot analog pin

int bpm;


void setup() {

 pinMode(BUZZER, OUTPUT); 

}
void loop() {

   bpm = map(analogRead(POT), 0, 1023, MIN_BPM, MAX_BPM); 
   tone(BUZZER, 2500);       
   delay(3000 / bpm);       
   noTone(BUZZER);           
   delay(60000 / bpm - (3000 / bpm)); // 60000 - buzzer delay       

}

EDIT: Fixed math (I hope). :slight_smile:

Or this. :slight_smile:

#include <SPI.h>
#include <Wire.h>
#define BUZZER  10      // buzzer pin
#define MIN_BPM 20      // minimum bpm value
#define MAX_BPM 240     // maximum bpm value
#define POT A0          // pot analog pin

int bpm;


void setup() {

 pinMode(BUZZER, OUTPUT); 

}
void loop() {

   bpm = map(analogRead(POT), 0, 1023, MIN_BPM, MAX_BPM); 
   tone(BUZZER, 2500);       
   delay(50);       
   noTone(BUZZER);           
   delay(60000 / bpm - 50); // 60000 - buzzer delay       

}

EDIT: Fixed math (I hope). :slight_smile:

Railroader:
Both outer ends of the pot looks like being connected to GND. One to GND, one to VCC is needed.

Indeed.

Make all your variables unsigned long and postfix numbers with UL.