Workshop for LID8 at AAU-CPH for using the Fadecandy
Go to file
Frederik Vanggaard 4242d4be0b Removed OPC files
2016-04-06 20:46:39 +02:00
EmptySketch Removed OPC files 2016-04-06 20:46:39 +02:00
IndividualColor Removed OPC files 2016-04-06 20:46:39 +02:00
TextLID Added text example spelling LID 2016-04-06 20:45:46 +02:00
LICENSE Added license 2016-04-04 13:19:16 +02:00
Presentation.pptx Updated Presentation and README 2016-04-06 20:42:22 +02:00
README.md Updated Presentation and README 2016-04-06 20:42:22 +02:00

Fadecandy Workshop

This is going to be a small guide for using the NeoPixels together with the Fadecandy controller. We are going to use a single 8x8 NeoPixel board and a single Fadecandy controller.

Components

We are going to use very few components:

  • 1x Adafruit NeoPixel 8x8
  • 1x Fadecandy
  • 4x Jumper cables (male to male)
  • Header pins
  • Breadboard
  • Mini USB cable
  • Power Supply

Soldering

This is a one time thing and I just did it to make the NeoPixels easier to use later on.

Take the header pins and put them so you have two sets of 3 pins and two sets of 2 pins.

First take the two sets of 3 pins and solder them on the back of the NeoPixel matrix so we can plug the matrix into the breadboard.

Next solder the two sets of 2 pins on the GPIO pin 0 and 7 on the Fadecandy. We are actually just going to use one of the ports (GPIO pin 0) but if we have header pins on both 0 and 7, it will be better fastened to the breadboard.

Wiring

The wiring is very simple. We have 4 jumper cables:

  • 2 groung
  • 1 power
  • 1 input

(source: https://github.com/scanlime/fadecandy)

We connect the top port (blue) on the GPIO port 0 to the DIN (input) pin on the NeoPixel matrix. The bottom port (black) to the ground pin on the NeoPixel and that's all for connecting the NeoPixels to the Fadecandy.

We are now going to need some power. There are two options, if we are just running a single board we can use USB power. So for this we need a USB cable with header pins in one end (as seen on the picture below).

Attach the cable to the board and attach a black jumper cable from ground on the USB cable to ground on the NeoPixels, and a red jumper cable from the power on the USB cable to the 5v input on the NeoPixels.

Code

Download the Fadecandy software from their GitHub site link and extract it somewhere on your computer.

Open the terminal (OS X/Linux) or command line (Windows) and go to your downloaded folder.

cd ~/Downloads/fadecandy-master

Inside that folder we need to go to the bin folder.

cd bin

Now we can run the fadecandy server depending on our platform. I'm using OS X.

open fcserver-osx

Connect the fadecandy to the computer using the mini USB cable and it should now be registered.

Open up the folder called examples/processing/grid8x8\_dot and open the processing sketch grid8x8\_dot.pde with Processing. Run it and the fadecandy should have a green light on and Processing should look like this

Connect the USB power to your computer and you should now be able to move your mouse around in the Processing sketch and change the light on the NeoPixel matrix.

If you don't have a USB cable with header pins on you can use a regular 5V ~2A power supply. Connect the ground and 5V pin from the NeoPixel matrix to the power supply and run the Processing sketch for the same result.

Making your own sketch

Lets try and set up an empty sketch using the template below:

OPC opc;

void setup() {
	size(500, 500, P3D);

	opc = new OPC(this, "127.0.0.1", 7890);
	opc.ledGrid8x8(0, width/2, height/2, height / 16.0, 0, false);
}

void draw() {
  background(0);
}

Here the important part is the ledGrid8x8 line. First we have a 0, this indicated that we have connected the led matrix to connector 0 on the fadecandy. Next we need to define the center of the matrix. This is done using width/2 and height/2. We also need to define the spacing between each LED. The spacing is approximately one LED in size, so we can use height/16. The next 0 is the rotation. Since we just use the default rotation we dont need to change this. false means that all the LEDs point in the same direction.

If we run this nothing will really happen except we get a black screen with 8x8 dots on.

We can change the individual colors using setPixel(index, color) in the draw function.

opc.setPixel(0, color(255,0,0));

The above code changes the color of the first pixel to red.

opc.setPixel(10, color(0,255,0));

The above code changes the 11th pixel to green.

This should make sense and be easy to work with.

Unfortunately each pixel does have a bit of color bleeding to nearby pixels, this can be prevented using a printed separator or another time of plate in front.

Webserver

It is easy to test and identify different fadecandy's using the port the fadecandy is set up to. Just go to localhost:port and play around

http://localhost:7890

Here is you you can identify the Fadecandy if multiple ones are connected or test all the LEDs. There is also an option to configure the server using JSON, but thats not something I want to get into now.