UNPKG

@iiot2k/gpiox

Version:

Input/Output on any gpio library

51 lines (39 loc) 1.08 kB
/* * example pulse realtime gpio output * * run: * > node pulse_rt_gpio.js * */ "use strict"; const gpiox = require("../gpiox"); const PIN_OUTPUT = 20; const PULSE1 = 5; // us const PULSE2 = 100; // us const PULSE3 = 10; // us const PULSE4 = 5000; // us console.log("*** puls rt gpio node.js example ***"); // init gpio gpiox.init_gpio(PIN_OUTPUT, gpiox.GPIO_MODE_OUTPUT, 0); console.log("pulse", PULSE1 + "us"); gpiox.pulse_rt_gpio(PIN_OUTPUT, PULSE1); // after 500ms PULSE2 setTimeout(function() { console.log("pulse", PULSE2 + "us"); gpiox.pulse_rt_gpio(PIN_OUTPUT, PULSE2); }, 500); // after 500ms PULSE3 setTimeout(function() { console.log("pulse", PULSE3 + "us"); gpiox.pulse_rt_gpio(PIN_OUTPUT, PULSE3); }, 1000); // after 500ms PULSE4 setTimeout(function() { console.log("pulse", PULSE4 + "us"); gpiox.pulse_rt_gpio(PIN_OUTPUT, PULSE4); }, 1500); // after 500ms stop program setTimeout(function() { gpiox.deinit_gpio(PIN_OUTPUT); console.log(" -> program stopped"); }, 2000);