Skip to content

Instantly share code, notes, and snippets.

@naokisekiguchi
Last active October 4, 2016 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naokisekiguchi/a3bf6c02a58ffc7dc8b7f6ef97954f1d to your computer and use it in GitHub Desktop.
Save naokisekiguchi/a3bf6c02a58ffc7dc8b7f6ef97954f1d to your computer and use it in GitHub Desktop.
CHIRIMENとherokuを使って20分でIoTを始める方法 ref: http://qiita.com/naokisekiguchi@github/items/84a497bde653568a12da
$ heroku login
Enter your Heroku credentials.
Email: name@example.com
Password:
$ git clone https://github.com/naokisekiguchi/gpio-on-the-web.git
$ cd gpio-on-the-web
$ heroku create
$ git push heroku master
$ heroku open
'use strict';
window.addEventListener('load', function (){
// WebGPIO LED Blink
navigator.requestGPIOAccess()
.then(gpioAccess=>{
var port = gpioAccess.ports.get(198);
var v = 0;
return port.export("out").then(()=>{
setInterval(function(){
v = v ? 0 : 1;
port.write(v);
if(v){document.querySelector("h2").className = "on";}
else{document.querySelector("h2").className = "off";}
},1000);
});
});
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment