The on-board flash memory can also be used to store MetaWear commands instead of sensor data. Recorded commands can be executed any time after being programmed with the Macro module.

import com.mbientlab.metawear.module.Macro;

final Macro macro = board.getModule(Macro.class);

Recording Commands

To record commands:

  1. Call startRecord to put the API in macro mode

  2. Use the MetaWear commands that you want programmed

  3. Exit macro mode with endRecordAsync

Macros can be set to run on boot by calling startRecord with true.

import com.mbientlab.metawear.module.Led;

final Led led = mwBoard.getModule(Led.class);

led.editPattern(Led.Color.GREEN, Led.PatternPreset.SOLID)
macro.endRecordAsync().continueWith(new Continuation<Byte, Void>() {
    public Void then(Task<Byte> task) throws Exception {
        Log.i("MainActivity", "Macro ID = " + task.getResult());
        return null;

Erasing Macros

Erasing macros is done with the eraseAll method. The erase operation will not occur until you disconnect from the board.