You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • Sharing a way how to setup neopixel, set color and send simple patterns - Many thanks to @Gordon who mentioned this possibility via Uint24Array().

    // load module
    var np = require('neopixel');
    
    //  pin data line is attached to
    var NPP= D16;
    
    // number of neopixel
    var countNP = 100;
    
    // use  Uint24Array  to store an address single pixel
    var neopixelStrip = new Uint24Array(countNP);
    
    // set color for  first and last pixel
    var color = {r:20,g:0,b:20};
    var c = color.g + (color.r << 8) + (color.b << 16);
    neopixelStrip.buffer[0] = c;
    neopixelStrip.buffer[countNP-1] = c;
    
    // flip neopixel
    np.write(NPP, neopixelStrip.buffer);
    
    

    Send a pattern all over the neopixel strip

    // Solution A
    // simple pattern "_  _  Green _  _"
    var fiveLEDs = new Uint24Array(5);
    fiveLEDs[2] = 30;
    // fill buffer with a pattern array and count 
    var nps = E.toUint8Array({data:fiveLEDs.buffer,cou­nt:20});
    
    // Solution B
    // fill buffer with pattern
    for ( i = 2; i < countNP; i +=5 ) { neopixelStrip.buffer[i] = 30;
    
About

Avatar for MaBe @MaBe started