obniz-led-onoff

node v8.17.0
version: 2.0.0
endpointsharetweet
// Runkit Endpoint Example const Obniz = require("obniz"); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const yourObnizId = "95824465" // write your obniz id app.get("/", (req, res) => { let obniz = new Obniz(yourObnizId); obniz.onconnect = async function(){ let led = obniz.wired("LED", {anode:10, cathode:11}); let changed = ""; if(req.query.led == "on"){ led.on(); changed = "on"; }else{ led.off(); changed = "off"; } obniz.resetOnDisconnect(false); obniz.close(); res.send("LED Changed to "+changed); } })
Created from: http://localhost:3000/doc/lessons_runkit
Loading…

no comments

    sign in to comment