Twitter: @am3thyst
Email: amy (at) amycheng.info
Initialize NeoPixel library
...map LED to pin
...turn pin on and off
Start Fadecandy Server
...start open pixel server
...map LED(s) to pixels
...draw to pixels
..either using Processing, Node.js, C++ and more
Use models
Do it (manually)
This example is included in the Fadecandy git repo
#!/usr/bin/env node
// Simple red/blue fade with Node and opc.js
var OPC = new require('./opc')
var client = new OPC('localhost', 7890);
function draw() {
var millis = new Date().getTime();
for (var pixel = 0; pixel < 512; pixel++)
{
var t = pixel * 0.2 + millis * 0.002;
var red = 128 + 96 * Math.sin(t);
var green = 128 + 96 * Math.sin(t + 0.1);
var blue = 128 + 96 * Math.sin(t + 0.3);
client.setPixel(pixel, red, green, blue);
}
client.writePixels();
}
setInterval(draw, 30);
This example can be found in the Fadecandy git repo.
#!/usr/bin/env node
// Simple particle system example with Node and opc.js
// Specify a layout file on the command line, or use the default (grid32x16z)
var OPC = new require('./opc');
var model = OPC.loadModel(process.argv[2] || '../layouts/grid32x16z.json');
var client = new OPC('localhost', 7890);
function draw() {
var time = 0.009 * new Date().getTime();
var numParticles = 200;
var particles = [];
for (var i = 0; i < numParticles; i++) {
var s = i / numParticles;
var radius = 0.2 + 1.5 * s;
var theta = time + 0.04 * i;
var x = radius * Math.cos(theta);
var y = radius * Math.sin(theta + 10.0 * Math.sin(theta * 0.15));
var hue = time * 0.01 + s * 0.2;
particles[i] = {
point: [x, 0, y],
intensity: 0.2 * s,
falloff: 60,
color: OPC.hsv(hue, 0.5, 0.8)
};
}
client.mapParticles(particles, model);
}
setInterval(draw, 10);
Amy Cheng
@am3thyst
amy@amycheng.info