Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const Obniz = require("obniz");
const express = require('@runkit/runkit/express-endpoint/1.0.0');
const app = express(exports);
const yourObnizId = "OBNIZ_ID" // write your obniz id
app.get('/', async (req,res) =>{
let obniz = new Obniz(yourObnizId);
let connected = await obniz.connectWait({timeout:10});
if(connected){
var servo = obniz.wired("ServoMotor", {signal:0,vcc:3, gnd:2});
servo.angle(100.0);
await obniz.wait(1000);
servo.angle(80.0);
setTimeout(function(){
obniz.close();
},1000);
res.json({status: "success"});
}else{
res.json({status: "error", reason : "Cannnot connect to obniz"});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.