Skip to content

Instantly share code, notes, and snippets.

@Krimsit
Last active November 16, 2017 12:08
Show Gist options
  • Save Krimsit/7a59b9f072535a2813fed2e5e2fea135 to your computer and use it in GitHub Desktop.
Save Krimsit/7a59b9f072535a2813fed2e5e2fea135 to your computer and use it in GitHub Desktop.
var buz = require('@amperka/buzzer').connect(P5);
var ir = require("@amperka/ir-receiver").connect(P0);
//var button = require('@amperka/button').connect(P1);
//var pot = require("@amperka/pot").connect(A1);
var arr = [
392, 392, 392, 311, 466, 392, 311, 466, 392,
587, 587, 587, 622, 466, 369, 311, 466, 392,
784, 392, 392, 784, 739, 698, 659, 622, 659,
415, 554, 523, 493, 466, 440, 466, 311, 369,
311, 466, 392
];
var timeArr = [
350, 350, 350, 250, 100, 350, 250, 100, 700,
350, 350, 350, 250, 100, 350, 250, 100, 700,
350, 250, 100, 350, 250, 100, 100, 100, 450,
150, 350, 250, 100, 100, 100, 450, 150, 350,
250, 100, 750
];
var i = 0;
ir.on("receive", function(code, repeat){
console.log("0x" + code.toString(16));
var one = "3fcc33f";
var two = "3fc639f";
if(code.toString(16) == one){
buz.toggle();
var Interval = setInterval(function(){
buz.frequency(arr[i]);
console.log("Частота: " + arr[i] + ", Time: " + timeArr[i]);
i++;
if(i == arr.length - 1) i = 0;
},timeArr[i]);
}
if(code.toString(16) == two){
clearInterval(Interval);
buz.toggle();
console.log("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment