Skip to content

Launchpad Paint Example

Daan van Berkel edited this page Oct 13, 2015 · 1 revision

We create an rudimentary paint application for the Launchpad.

var colors = ['off', 'red', 'green', 'orange'];

launchpad.connect()
    .then(function(pad){
        var color = 'red';
        pad.clear();
        colors.forEach(function(color, index){
            pad.controlButton(index).turn(color);
        });
        pad.controlButton(7).turn(color);
        pad.on('press', function(button){
            if (button.isControl()){
                color = colors[button.id] || colors[0];
            }
            pad.controlButton(7).turn(color);
        });
        pad.on('press', function(button){
            if (!button.isControl()){
                button.turn(color);
            }
        });
        pad.on('press', function(button){
            console.log('%s, %s', button.channel, button.note);
        });
        window.pad = pad;
    });
Clone this wiki locally