Created
December 7, 2018 14:27
-
-
Save yasugahira0810/9cd8382df74089b6a9170f31651aa25d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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