-
Notifications
You must be signed in to change notification settings - Fork 18
NeoPixel Jewel Setup
#NeoPixel Wiring Instructions
The IoT Solution Accelerator also includes a comprehensive library to drive and control NeoPixel strips, rings, grids and jewels. There is also support for chaining multiple NeoPixel Grids together and treating as one wide panel.
Ideally you should solder the wires to the back of the Jewel otherwise ensure there is good electrical contact and use some sticky tape on the back of the Jewel to hold the wires in place. It's really important to ensure no wires poking out the front of the Jewel are touching and shorting out the circuit.
##Maker Den Project
Next ensure you have the latest version of the Maker Den project from Github. Either resync your clone or Download ZIP
If you have been following the Maker Den Lab Guide then ensure
- StartNetworkServices("device id", true, "network id");
- After the StartNetworkServices and before the first using statement add
- using (NeoPixelJewelRun jewel = new NeoPixelJewelRun("jewel"))
- When you've updated your code then it should look similar to the code below.
- Ensure the Netduino is connected to the PC using the USB cable and the Ethernet cable is plugged in to the Netduino and there is an active Internet connection.
- Deploy your code to the Netduino.
- Give it 30 seconds for the Netduino to restart and connect to the Internet and then the NeoPixel Jewel should light up with a series of colour patterns. Feel free to create your own patterns in the NeoPixelJewelRun.cs found in the Coatsy.MicroFramework project under \NeoPixel\Jewel.
Watch the Netudino Plus 2 and NeoPixel Jewel in action on YouTube
Your Program.cs file in the MakerDen project should look similar to this code.
using Coatsy.Netduino.NeoPixel.Jewel;
using Glovebox.Adafruit.Mini8x8Matrix;
using Glovebox.MicroFramework.Sensors;
using Glovebox.Netduino.Actuators;
using Glovebox.Netduino.Sensors;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using System.Threading;
namespace MakerDen {
public class Program : MakerBaseIoT {
public static void Main() {
// main code marker
StartNetworkServices("emul", true, "network id");
using (NeoPixelJewelRun jewel = new NeoPixelJewelRun("jewel"))
using (SensorTemp temp = new SensorTemp(Pins.GPIO_PIN_D8, 10000, "temp01"))
using (SensorLight light = new SensorLight(AnalogChannels.ANALOG_PIN_A0, 1000, "light01"))
using (rgb = new RgbLed(Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, "rgb01")) {
temp.OnBeforeMeasurement += OnBeforeMeasure;
temp.OnAfterMeasurement += OnMeasureCompleted;
light.OnBeforeMeasurement += OnBeforeMeasure;
light.OnAfterMeasurement += OnMeasureCompleted;
Thread.Sleep(Timeout.Infinite);
}
}
}
}
From the Netduino Technical Specifications you will see that you should not draw more than 25 milliamps from any one pin on a Netduino.
For small NeoPixel strings dimly lit you can get away with powering the NeoPixel directly from the Netduino. Connect the +5v to the +5v, ground to the ground and the Data-In (din) pin to Pin 11. But be warned, you may damage the Netduino doing this, so don't over do it and use the Low Power colours and pallettes in the NeoPixel framework.
The safest way is to power a string of NeoPixels seperately. Follow this Arduino wiring example but connect the Data-In (din) pin to pin 11 on the Netduino.
.
Below is a code example of driving a Happy Birthday message across three daisy chained 8x8 NeoPixel NeoMatrix Grids.
// program.cs
using Coatsy.Netduino.NeoPixel;
using Coatsy.Netduino.NeoPixel.Grid;
using System.Threading;
namespace MakerDen {
public class Program {
public static void Main() {
// main code marker
// Create new instance of a grid named grid01, there are three 8x8 grids daisy chained
NeoPixelGrid8x8 grid = new NeoPixelGrid8x8("grid01", 3);
while (true) {
// Scroll Happy Birthday in from the right
grid.ScrollStringInFromRight("Happy Birthday", grid.PaletteHotLowPower, 10);
Thread.Sleep(500);
// write the letter K on the first panel
grid.DrawLetter('K', Pixel.ColourLowPower.HotRed, 0);
// write the letter I on the second panel
grid.DrawLetter('I', Pixel.ColourLowPower.HotGreen, 1);
// write the letter T on the third panel
grid.DrawLetter('T', Pixel.ColourLowPower.HotBlue, 2);
// now create a randomised pattern by shuntting alternate rows right and left
for (int i = 0; i < grid.Columns * grid.Panels / 2; i++) {
grid.ColumnRollRight(0);
grid.ColumnRollRight(0);
grid.ColumnRollLeft(2);
grid.ColumnRollLeft(2);
grid.ColumnRollRight(4);
grid.ColumnRollRight(4);
grid.ColumnRollLeft(6);
grid.ColumnRollLeft(6);
// now draw the frame buffer to the neopixel grids
grid.FrameDraw();
Thread.Sleep(10);
}
Thread.Sleep(1000);
// now draw the letters KIT in different colours from the PaletteHotLowPower palette
foreach (var c in grid.PaletteHotLowPower) {
grid.DrawLetter('K', c, 0);
grid.DrawLetter('I', c, 1);
grid.DrawLetter('T', c, 2);
// now draw the frame buffer to the neopixel grids
grid.FrameDraw();
Thread.Sleep(500);
}
// clear the frame buffer
grid.FrameClear();
// scroll in the heart symbols in from the left
grid.ScrollSymbolInFromLeft(new NeoPixelGrid8x8.Symbols[] { NeoPixelGrid8x8.Symbols.Heart, NeoPixelGrid8x8.Symbols.Heart, NeoPixelGrid8x8.Symbols.Heart }, Pixel.ColourLowPower.HotRed, 10);
Thread.Sleep(500);
// now redraw the heart symbols in different colours
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotBlue, 0);
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotBlue, 1);
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotBlue, 2);
grid.FrameDraw();
Thread.Sleep(500);
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotGreen, 0);
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotGreen, 1);
grid.DrawSymbol(NeoPixelGrid8x8.Symbols.Heart, Pixel.ColourLowPower.HotGreen, 2);
grid.FrameDraw();
Thread.Sleep(500);
}
}
}
}