Fritzing diagram: docs/breadboard/switch-magnetic-door.fzz
Run this example from the command line with:
node eg/switch-magnetic-door.js
const {Board, Switch} = require("johnny-five");
const board = new Board();
board.on("ready", () => {
// Contact Mode: Normally Open (default!)
const sw = new Switch(7);
sw.on("open", () => console.log("open"));
sw.on("close", () => console.log("close"));
});
Copyright (c) 2012-2014 Rick Waldron [email protected] Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.