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);
}