Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let config = {};
servo = new five.Servo({
pin: 3,
type: "continuous"
});
strip = new pixel.Strip({
board: this,
controller: "FIRMATA",
strips: [{pin: 4, length: 190},],
gamma: 2.8,
});
toggle = new five.Switch(6);
toggle.on("close", function () {
if (config['enable-toggle-switch']) {
// Set to Enlightened
portalRef.child('faction').set(portalFactionEnum.enlightened.value);
} else {
console.log("Toggle switch used when disabled by config");
}
});
toggle.on("open", function () {
if (config['enable-toggle-switch']) {
// Set to Resistance
portalRef.child('faction').set(portalFactionEnum.resistance.value);
function addSwitch(index, myPin, myId) {
devices[index] = new five.Switch({
pin: myPin,
id: myId
});
// event listener call back function for switch going to 'off'
var switchOffCallbackChange = function () {
if (debugLevel >= 1) {
console.log(' switch callback ' + index, devices[index].id + ' off');
}
connection.send('dataUpdate/' + devices[index].id + '/' + 0)
};
// event listener call back function for switch going to 'on'
var switchOnCallbackChange = function () {
if (debugLevel >= 1) {
console.log(' switch callback ' + index, devices[index].id + ' on');
board.on("ready", () => {
const spdt = new Switch("a0");
const throttle = new Sensor("b0");
// See the comments below for more information about
// the pins shown in this pin array argument.
const motor = new Motor([ "a5", "a4", "a3" ]);
spdt.on("open", () => {
motor.stop().forward(motor.speed());
});
spdt.on("close", () => {
motor.stop().reverse(motor.speed());
});
throttle.on("change", () => {
motor.speed(throttle.value >> 2);
board.on('ready', () => {
let reed = five.Switch(8);
reed.on('open', () => {
device.emit('door-open', { timestamp: Date.now() });
});
device.emit('ready');
});
};
board.on('ready', function() {
document.getElementById('board-status').src = 'icons/ready.png'
var led = new five.Led(12)
var spdt = new five.Switch(9)
spdt.on('open', function() {
led.off()
document.getElementById('led-status').src = 'icons/led-off.png'
})
spdt.on('close', function() {
led.on()
document.getElementById('led-status').src = 'icons/led-on.png'
})
})