From 8e051c51d73905a7f776cc985176ed89aa8e22ff Mon Sep 17 00:00:00 2001 From: Frederik Vanggaard Date: Mon, 4 Apr 2016 21:47:09 +0200 Subject: [PATCH] Updated readme and added two new sketches --- EmptySketch/EmptySketch.pde | 14 ++++++++++ IndividualColor/IndividualColor.pde | 31 +++++++++++++++++++++ README.md | 43 +++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 EmptySketch/EmptySketch.pde create mode 100644 IndividualColor/IndividualColor.pde diff --git a/EmptySketch/EmptySketch.pde b/EmptySketch/EmptySketch.pde new file mode 100644 index 0000000..73b085d --- /dev/null +++ b/EmptySketch/EmptySketch.pde @@ -0,0 +1,14 @@ +OPC opc; + color c = color(0,0,255); + +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); + +} \ No newline at end of file diff --git a/IndividualColor/IndividualColor.pde b/IndividualColor/IndividualColor.pde new file mode 100644 index 0000000..ba55c46 --- /dev/null +++ b/IndividualColor/IndividualColor.pde @@ -0,0 +1,31 @@ +OPC opc; + color c = color(0,0,255); + +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); + + for (int i = 0; i < 8; i++) { + opc.setPixel(i+8*0, color(255,0,0)); + opc.setPixel(i+8*1, color(0,255,0)); + opc.setPixel(i+8*2, color(0,0,255)); + + opc.setPixel(i+8*3, color(127,0,0)); + opc.setPixel(i+8*4, color(0,127,0)); + opc.setPixel(i+8*5, color(0,0,127)); + + opc.setPixel(i+8*6, color(100,100,100)); + opc.setPixel(i+8*7, color(200,200,200)); + } + + opc.writePixels(); + +} + + \ No newline at end of file diff --git a/README.md b/README.md index 5ac2bc7..e6f82c3 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,46 @@ Connect the USB power to your computer and you should now be able to move your m 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. ![](http://www.drudoo.com/wp-content/uploads/2016/03/Photo-Feb-15-7-10-31-PM-e1456939241663.jpg) + + + +## 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. + +## Another example + +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