The source code for these templates can be found here: https://github.com/gomobile?query=iotapp or download the Intel® XDK IoT Edition to check out all the node.js IoT application templates.
Introduction
Intel XDK® IoT Edition is a HTML5 hybrid and node.js application development environment that allow users to deploy, run, debug on various IoT platforms such as the Intel® Galileo and Edison board running the IoT Development Kit Linux Image and utilizes the Grover Starter Kit Plus – IoT Intel® Edition. With the starter kit and Linux* image installed, your development platform is ready to connect to XDK IoT Editon and run your node.js applications. Along with development features, this development environment provides various node.js templates and samples intended for running on Intel IoT platforms. For more information on getting started, go to https://software.intel.com/en-us/html5/documentation/getting-started-with-intel-xdk-iot-edition.
Purpose
The templates distributed within Intel® XDK IoT Edition provides compelling functionality such as access to various ways to handle analog and digital data transmitted to plus received from sensor(s) connected to any IO pin(s) among other functionality. In order to communicate with sensors, each of the relevant templates uses the MRAA Sensor Communication Library. The intent of this library is to make it easier for developers and sensor manufacturers to map their sensors & actuators on top of supported hardware and to allow control of low level communication protocol by high level languages & constructs.
Design Considerations
Each of the templates require the mraa library and xdk daemon to be installed on your board. These two requirements are included in the IoT Development Kit Linux Image which enables communication between your board and XDK IoT Edition plus access to the IO pins.
Development /Testing
Each of the templates have been test on Intel® Galileo Generation 1 and 2 boards as well as the Intel® Edison board.
Intel® XDK IoT Edition IoT node.js templates
OnBoard LED Blink
A simple node.js application intended to blink the onboard LED on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-onboard-led-blink
var mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
var myOnboardLed = new mraa.Gpio(13);
myOnboardLed.dir(mraa.DIR_OUT);
Analog Read
A simple node.js application intended to read data from Analog pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-analog-read
var mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
var analogPin0 = new mraa.Aio(0);
var analogValue = analogPin0.read();
console.log(analogValue);
Digital Read
A simple node.js application intended to read data from Digital pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-digital-read
var mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
var myDigitalPin6 = new mraa.Gpio(6);
myDigitalPin6.dir(mraa.DIR_IN);
Digital Write
A simple node.js application intended to write data to Digital pins on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-digital-write
var mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
var myDigitalPin5 = new mraa.Gpio(5);
myDigitalPin5.dir(mraa.DIR_OUT);
myDigitalPin5.write(1);
PWM
A simple node.js application intended to read and write analog values to fade a LED from Digital pins (PWM) on the Intel based development boards such as the Intel(R) Galileo and Edison with Arduino breakout board. Source: https://github.com/gomobile/iotapp-template-pwm
var mraa = require("mraa");
var pwm3 = new mraa.Pwm(3, -1, false);
pwm3.enable(true);