Skip to content

Instantly share code, notes, and snippets.

@Krimsit
Last active November 16, 2017 12:39
Show Gist options
  • Save Krimsit/b00f25374599bc25faff5d52fe73d3c4 to your computer and use it in GitHub Desktop.
Save Krimsit/b00f25374599bc25faff5d52fe73d3c4 to your computer and use it in GitHub Desktop.
var buz = require('@amperka/buzzer').connect(P5);
var button = require('@amperka/button').connect(P8);
var pot = require("@amperka/pot").connect(A0);
var ir = require("@amperka/ir-receiver").connect(P0);
function ReadVal(){
var val = pot.read();
var val1 = Math.floor(val * 10000);
console.log(val1);
buz.frequency(val1);
}
button.on("press", function(){
setInterval(ReadVal, 10);
buz.turnOn();
console.log('press');
});
button.on("release", function(){
buz.turnOff();
console.log('release');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment