Skip to content

Instantly share code, notes, and snippets.

@ikr7
Created June 10, 2014 11:34
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 ikr7/d5dc0d335bfd8c2d970d to your computer and use it in GitHub Desktop.
Save ikr7/d5dc0d335bfd8c2d970d to your computer and use it in GitHub Desktop.
ボタンがおされたらアレみたいなやつ
var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
setInterval(check, 100);
function check(){
b.digitalRead('P8_19', checkButton);
}
var prevValue = 0;
function checkButton(x){
if(x.value !== prevValue){
console.log(
['ボタンから離れたよ', 'ボタンが押されたよ'][x.value]
);
}
prevValue = x.value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment