How to use mraa - 10 common examples

To help you get started, we’ve selected a few mraa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel-iot-devkit / how-to-code-samples / earthquake-detector / javascript / dfrobot.js View on Github external
exports.init = function(config) {
  if (config.platform == "firmata") {
    // open connection to firmata
    mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");

    ax = new mraa.Aio(3 + 512); // A3
    ay = new mraa.Aio(2 + 512); // A2
    az = new mraa.Aio(1 + 512); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(520, 521, 516, 517, 518, 519, 512);
  } else {
    ax = new mraa.Aio(3); // A3
    ay = new mraa.Aio(2); // A2
    az = new mraa.Aio(1); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(8, 9, 4, 5, 6, 7, 0);
  }

  return;
}
github Losant / losant-mqtt-js / examples / intel-edison.js View on Github external
* Arduino Breakout board with the following connections.
 *
 * LED connected to GPIO pin 7.
 * TMP36 temperature sensor connected to analog input A0.
 *
 * Copyright (c) 2019 Losant IoT, Inc. All rights reserved.
 * https://www.losant.com
 */

 /* eslint no-console: "off"*/

var mraa = require('mraa');
var Device = require('losant-mqtt').Device;

// Reading temperature from analog input.
var temp = new mraa.Aio(0);

// Blinking an LED everytime temperature is read.
var led = new mraa.Gpio(7);
led.dir(mraa.DIR_OUT);

// Construct a device instance.
var device = new Device({
  id: 'my-device-id',
  key: 'my-access-key',
  secret: 'my-access-secret'
});

// Connect device to Losant.
device.connect();

// Attach event listener for commands.
github intel-iot-devkit / how-to-code-samples / earthquake-detector / javascript / dfrobot.js View on Github external
exports.init = function(config) {
  if (config.platform == "firmata") {
    // open connection to firmata
    mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");

    ax = new mraa.Aio(3 + 512); // A3
    ay = new mraa.Aio(2 + 512); // A2
    az = new mraa.Aio(1 + 512); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(520, 521, 516, 517, 518, 519, 512);
  } else {
    ax = new mraa.Aio(3); // A3
    ay = new mraa.Aio(2); // A2
    az = new mraa.Aio(1); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(8, 9, 4, 5, 6, 7, 0);
  }

  return;
}
github intel-iot-devkit / how-to-code-samples / earthquake-detector / javascript / dfrobot.js View on Github external
exports.init = function(config) {
  if (config.platform == "firmata") {
    // open connection to firmata
    mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");

    ax = new mraa.Aio(3 + 512); // A3
    ay = new mraa.Aio(2 + 512); // A2
    az = new mraa.Aio(1 + 512); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(520, 521, 516, 517, 518, 519, 512);
  } else {
    ax = new mraa.Aio(3); // A3
    ay = new mraa.Aio(2); // A2
    az = new mraa.Aio(1); // A1
    screen = new (require("jsupm_lcdks").LCDKS)(8, 9, 4, 5, 6, 7, 0);
  }

  return;
}
github intel-iot-devkit / how-to-code-samples / fire-alarm / javascript / dfrobot.js View on Github external
exports.init = function(config) {
  if (config.platform == "firmata") {
    // open connection to firmata
    mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");

    temp = new mraa.Aio(3 + 512); // A3
    buzzer = new mraa.Gpio(16 + 512); // aka A2
    screen = new (require("jsupm_lcdks").LCDKS)(520, 521, 516, 517, 518, 519, 512);
    voltage = 0.33;
  } else {
    temp = new mraa.Aio(3); // A3
    buzzer = new mraa.Gpio(16); // aka A2
    screen = new (require("jsupm_lcdks").LCDKS)(8, 9, 4, 5, 6, 7, 0);
    voltage = 1.0;
  }

  buzzer.dir(mraa.DIR_OUT);
  buzzer.write(0);

  return;
}
github issmirnov / calhacks2014 / main.js View on Github external
function light(LED, duration) {
    'use strict';
    var digital_pin_D = new mraa.Gpio(LED);
    digital_pin_D.dir(mraa.DIR_OUT);
    digital_pin_D.write(1);
    console.log("Light ON!!!");
    sleep.sleep(duration);
    digital_pin_D.write(0);
    console.log("Light OFF!!!");
}
github eclipse / mraa / examples / javascript / GPIO_DigitalWrite.js View on Github external
/*
 * Author: Dan Yocom 
 * Copyright (c) 2014 Intel Corporation.
 *
 * SPDX-License-Identifier: MIT
 */

"use strict";

const mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console

let myDigitalPin = new mraa.Gpio(5); //setup digital read on pin 5
myDigitalPin.dir(mraa.DIR_OUT); //set the gpio direction to output
myDigitalPin.write(1); //set the digital pin to high (1)
github intel / intel-iot-services-orchestration-layer / node_modules / hope-demo / startkit / thing_bundle / temperature / measureTemp / start.js View on Github external
may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var m = require("mraa");
shared.pin = new m.Aio(CONFIG.pin);
done();
github intel / intel-iot-services-orchestration-layer / demo / startkit / thing_bundle / moisture_sensor / measureMoist / start.js View on Github external
may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var m = require("mraa");
shared.pin = new m.Aio(CONFIG.pin);
done();
github intel / intel-iot-services-orchestration-layer / demo / startkit / thing_bundle / general / analogRead / start.js View on Github external
may be used to endorse or promote products derived from this software
      without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var m = require("mraa");
shared.pin = new m.Aio(CONFIG.pin);
done();

mraa

IO library that helps you use I2c, SPI, gpio, uart, pwm, analog inputs (aio) and more on a number of platforms such as the Intel galileo, the Intel edison and others

MIT
Latest version published 7 years ago

Package Health Score

48 / 100
Full package analysis

Popular mraa functions