Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
* 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.
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;
}
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;
}
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;
}
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!!!");
}
/*
* 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)
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();
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();
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();