Metronome on Thingy:52

Posted on
  • Hi guys,

    I just wrote a very basic code aiming at providing the metronome function on the Thingy:52.
    I'm posting it here in case anyone's interested...

    It was inspired by this much more elaborated Bangle.js app.
    However, usage is pretty easy:
    1) a short press on the button increases/decreases the bpm
    2) a long press on the button changes direction of the setting

    The blue led flashes on a long press
    The red led flashes when bpm is reduced
    The green led flashes when bpm is increased

    var dir=1;
    var bpm=60; 
    
    function beep() {
      analogWrite(D27,0.5,{freq:440});
      digitalPulse(D29,1,50);
    }
    
    function onInit()
    {
      setWatch(function(e){
        var isLong = (e.time-e.lastTime)>0.4;
        if(isLong)
        {
          analogWrite(D27,0.5,{freq:392});
          digitalPulse(D29,1,50);
          digitalPulse(LED3,1,100);
          dir=!dir;
        }
        if(dir)
        {
          bpm *=1.1;
          digitalPulse(LED2,1,100);
        }
        else
        {
          bpm *=0.91;
          digitalPulse(LED1,1,100);
        }
        clearInterval(interval);
        interval = setInterval(beep, 60000 / bpm);
      }, BTN1, {repeat:true, debounce:50, edge:"falling"});
    
      interval = setInterval(beep, 60000 / bpm);
      LED2.reset();
    
    }
    
    save();
    
  • Nice - thanks!

  • Cool, have you thought about 2/4 or 3/4 or 4/4 times and flashing a different led on 1 ?

  • No, I haven't. The reason is simple to understand: I absolutely know nothing about musicology ;-)

    I just made a quick, basic, easy to use metronome, for my girlfriend who's learning to play piano.
    Pulsing a LED at regular interval is easy to do, but what do you mean by 2/4, 3/4 or 4/4 times? To easily switch from a X bpm to a X*2/4 or X*3/4 by pressing the button?

  • OK I get it... Well this is far to much elaborated for such a basic app like mine. However it may be something useful for the metronome app . Moreover, Bangle.js and its display would be more adapted to indicate the time signature, compared to the few LEDs on the Thingy:52 :-)

  • Yes, definitely :)

    I did some tests a couple month ago...


    1 Attachment

    • Metronom.jpg
  • My internal name for this is Feel the Beat because it vibs :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Metronome on Thingy:52

Posted by Avatar for Jean-Philippe_Rey @Jean-Philippe_Rey

Actions