0

I want a buzzer to beep $X$ times in $t$ seconds, but I don't want it to have a regular interval (something like $t/X$). Instead, I want the interval to linearly decrease, so it "beeps faster" as it approaches the end.

Each beep lasts $b$ seconds.

I think that I need to specify at least one of the intervals, so the last one is $i$.

Ultimately, I wanted to be able to calculate this on the fly on an Arduino, so I don't have to keep a list of all intervals, just those few variables.

I believe this problem is about derivatives, but I'm really struggling to figure out how to apply them to it.

For the exact project I'm working on, the variables would be the following:

$X = 80$

$t = 40s$

$b = 120ms$

$i = 30ms$

So in short, I want 80 beeps of 120ms to play in 40s, with the interval between them linearly decreasing, and the last two ones being 30ms apart.

And I fear this is way simpler than I'm imagining, but I'm struggling a lot with it, so I decided to ask it here.

Edit 01: My progress so far was to think of this problem as a graph of the intervals by the beep number.

That would give me a trapezoid whose area is $t - X * b$, as $t$ also contains the time each beep was playing, not only their intervals, so we subtract that.

The smaller base of the trapezoid (its rightmost side on the graph) would be $i$, and the larger base would be the first interval. Its height (that on the graph would be its base) is $X$.

With that, I believe I can use some basic geometry to get the missing values, and perhaps also come up with a formula that will give me the intervals using just those variables that I've declared.

  • Does the timer end when the last beep finishes? – Math1000 Oct 23 '19 at 17:16
  • What do you mean exactly by "linearly decreasing?" That if the last gap is 30ms, the gap before that should be 60ms, and the one before that 90ms, and so on? – Math1000 Oct 23 '19 at 17:23
  • 1
    The first beep starts at $t = 0ms$ and ends at $t = 120ms$ ($120ms$ after), the last beep ends at $t = 40000ms$, so the last beep started at time $t = 39880ms$ ($120ms$ before), and the beep before that ended at $t = 39850ms$ ($30ms$ before) and started at $t = 39730ms$ ($120ms$ before) (not sure if this formatting works here...). – Micael Jarniac Oct 24 '19 at 18:58
  • 1
    As for "linearly decreasing", I mean that the rate at which the intervals get smaller is constant, so for example, if the interval between beep one and beep two is $200ms$, and between beep two and beep three is $180ms$, the interval between beep three and four must be $160ms$, as in this example the interval decreases by $20ms$ after every beep. – Micael Jarniac Oct 24 '19 at 19:01
  • For what its worth, a list of all the intervals doesn't sound like it'd take that much more space than these variables? Why calculate on the fly when it can be precalculated? – Math1000 Oct 25 '19 at 03:30
  • Well, that's mostly because I wanted it to be easily configurable. So say I want it to last 60 seconds instead of 40, I can just change that one variable and all intervals will change accordingly. Same goes for changing how many beeps I want and so on. I am currently using a roughly estimated list of all the intervals (that I calculated from opening on Audacity an audio file that has the beeping I'm trying to mimic and noting the timecodes). – Micael Jarniac Oct 25 '19 at 13:48

0 Answers0