Using MRAA in Node.js

libmraa provides node.js bindings to develop applications in node.js on your LinkIt Smart 7688 development platform. A reference application to control the LED light with libmraa and node.js is presented.

Installing MRAA

Libmraa and its node.js bindings are already installed in the system image of the LinkIt Smart 7688 development board — no need to install it again.

Controlling the on-board LED

To control the LED in node.js: 


  1. Launch the system console
  2. Create a node.js app:

    mkdir app  
    cd app  
    npm init 
  3. Create an app.js file with following content:

    var m = require('mraa');                                         
    var ledState = true;   
    var myLed = new m.Gpio(44); 
    function periodicActivity() {
      myLed.write(ledState ? 1 : 0);
      ledState = !ledState;        
      setTimeout(periodicActivity, 1000);
  4. Execute the application:

    node app  

The Wi-Fi LED (orange) should now start to blink continuously for every second.

Controlling other peripherals

You can also use libmraa to control PWM, I2C, SPI and UART peripherals. Find more information on the APIs at the MRAA website. Note that libmraa enables to switch the pin mode when needed.