Last active
October 4, 2016 08:28
-
-
Save naokisekiguchi/a3bf6c02a58ffc7dc8b7f6ef97954f1d to your computer and use it in GitHub Desktop.
CHIRIMENとherokuを使って20分でIoTを始める方法 ref: http://qiita.com/naokisekiguchi@github/items/84a497bde653568a12da
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
$ heroku login | |
Enter your Heroku credentials. | |
Email: name@example.com | |
Password: |
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
$ git clone https://github.com/naokisekiguchi/gpio-on-the-web.git | |
$ cd gpio-on-the-web | |
$ heroku create |
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
$ git push heroku master | |
$ heroku open |
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
'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