light.scale([0, 255]).on('data', function(){
   pixels = [];
   for(var i = 0; i < 120; i++){
     pixels.push([this.value, this.value, this.value]);
   }
   client.put_pixels(strip.id, pixels);
 });
Example #2
0
// Here's how you move the ball
  function moveBall() {
    grid[y*ylen+x] = bgnd;    // Turn off ball in present location
    x += xdir;                // Move in the current direction
    if(x<0 || x>xlen-1) {     // See if you have fallen off either edge
      x = xlen/2;             // If so, restart in middle
    }
    grid[y*ylen+x] = color;   // Draw ball in new location
    client.put_pixels(strip.id, grid);  // Display the grid
    setTimeout(moveBall, ms); // Schedule the next ball move
  }
 setInterval(function(){
   client.put_pixels(strip.id, pixels);
   new_pixel = pixels[0];
   pixels = pixels.slice(1);
   pixels.push(new_pixel);
 }, 200);