Breadboard for "Switch - Magnetic Door"
Fritzing diagram: 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"));
});
Learn More