Skip to content

Instantly share code, notes, and snippets.

@Krimsit
Last active November 16, 2017 12:11
Show Gist options
  • Save Krimsit/02ee9314d591ffca907c1a6a51038de8 to your computer and use it in GitHub Desktop.
Save Krimsit/02ee9314d591ffca907c1a6a51038de8 to your computer and use it in GitHub Desktop.
var buz = require('@amperka/buzzer').connect(P5);
var led = require('@amperka/led').connect(P2);
var button = require('@amperka/button').connect(P8);
function getRand(){
return Math.round(Math.random());
}
function TO(f, t){
setTimeout(function(){
f();
}, t);
}
button.on("press", function(){
if(getRand() == 1){
TO(buz.beep(.3), 0.05);
TO(led.blink(.3), 0.05);
TO(buz.beep(.3), 0.05);
TO(led.blink(.3), 0.05);
TO(buz.beep(.3), 0.05);
TO(led.blink(.3), 0.05);
}
else{
console.log("LUZER!!!!AZAZA");
}
});
console.log(getRand());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment