LED blinking indefinitely in JavaScript

I would like to replicate the indefinite red blinking that occurs in the MetaBase app, but I haven't been able to translate the underlying code.

Where can I use the const to REPEAT_INDEFINITELY that is listed in the docs? I saw how it can be used in Java but not JavaScript

const uint8_t   MBL_MW_LED_REPEAT_INDEFINITELY = 0xff

 var pattern = new MetaWear.LedPattern();
    // Load a LED pattern already in firmware
    MetaWear.mbl_mw_led_load_preset_pattern(pattern.ref(), MetaWear.LedPreset.BLINK);

 // Send pattern to Board
    MetaWear.mbl_mw_led_write_pattern(device.board, pattern.ref(), MetaWear.LedColor.RED);

// Tell board to play pattern

 setTimeout(function () {
      device.on('disconnect', function () {
      // Stop LED


  • For reference, I tried to assign:

     let pattern = new MetaWear.LedPattern(repeat_count = MBL_MW_LED_REPEAT_INDEFINITELY);

    But it threw a reference error.

    It's hard to figure out what the syntax is supposed to be with the SDK sometimes.

  • Nevermind - I hard coded a value for the unsigned integer.

  • hey @jjm345,
    It sounds like you might just have had the wrong type for MBL_MW_LED_REPEAT_INDEFINITELY.

Sign In or Register to comment.