Skip to content

Instantly share code, notes, and snippets.

@urish

urish/mongoose-neopixel.js Secret

Last active Jul 24, 2017
Embed
What would you like to do?
load('api_gpio.js');
load('api_neopixel.js');
load('api_timer.js');
load('api_sys.js');
load('api_rpc.js');
print('Hello, JavaScript Israel!');
let pixels = 8;
let strip = NeoPixel.create(2, pixels, NeoPixel.GRB);
function setColor(r, g, b) {
for (let i = 0; i < pixels ; i++) {
strip.setPixel(i, r, g, b);
}
strip.show();
}
setColor(255, 0, 0);
/*
let value = 1;
Timer.set(1000, 1, function() {
setColor(value?255:0, 0, 255);
value = !value;
}, null);
*/
/*
RPC.addHandler('color', function(args) {
setColor(args[0], args[1], args[2]);
return null;
});
*/
// mos call --port http://192.168.43.123/rpc color [0,255,0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment