Click this for NoviceGuard main page

SmartLEDs (WS2812-Bs) for NoviceGuard

This page will introduce you to a daughter board for NoviceGuard. You do not need a NoviceGuard to use what is presented here. It will be of little use if you do not have an Arduino.


This is an approximation of what my daughter board for NoviceGuard, with WS2812 SmartLEDs looked like. The colors... especially the bright "LED" blue at the lower left... are MUCH prettier in the real world.

See it in action in a 40 second YouTube clip of the NoviceGuard/ DS2812/ SmartLEDs demonstrator... which doesn't do the vivid colors justice!

The daughter board lets you plug WS2812 SmartLEDs into an Arduino. SmartLEDs are really cool, worth the very small nuisances involved in getting started...a power supply, a capacitor, a resistor, and some SmartLEDs, and you are Good To Go. A SmartLED is a small (5mm on a side) module with a red, a green and a blue LED... very BRIGHT! LED... and some control circuits. With just one output line from something like an Arduino, you can set each of those LEDs to any brightness from 0-255. From more than 10cm away, the three LEDs blend into a single point of color... any one of 16 million colors.

Red and yellow and green and brown and scarlet and black and ochre and peach and ruby and olive and violet and fawn And lilac and gold and chocolate and mauve and cream and crimson and silver and rose.... if Tim Rice will forgive me using his line.

The hardware

This is a daughther board for the NG_PwrDemand_2 power scenario.

You need some SmartLEDs. I'd buy these connected up for you, if I were you. The small board you'll see in the video is for "proof of concept. It works. But is fiddly to assemble. But if you REALLY want to go that route, get in touch. (Eddress at bottom of page.) You'll find details of a nice SmartLED array to begin with, and some more technical details, at a page I did about SmartLEDs in general. The page you are reading here is about marrying SmartLEDs to an Arduino across a NoviceGuard. The other page will also tell you about the essential (no, you can't leave them 'til later) power supply, capacitor and resistor.

The daughter board (or your substitute) has three pins to go into one of the NoviceGuard's input daughter board positions. (All this is "taken care of" for you, when you use an actual daughter board, of course.)

The software


You don't have to use a NoviceGuard to benefit from this page. The NoviceGuard just makes it easier for novices to hook things up. (We will be using four inputs... you don't "need" any, but with inputs, you can select different patterns for display on the SmartLEDs.) The inputs we need are on the NoviceGuard. I've done a separate page on doing NoviceGuard challenges/ programs without a NoviceGuard. (You just have to provide.. not hard... your users with the things NoviceGuard would give them. For this exercise, four buttons (or fewer, if you don't mind losing functionality) to press that the Arduino can "see" being pressed.

A library is provided for NoviceGuard users: "NovGrdCore".

You don't have to use the library to benefit from this page. There's more on Do I need the NovGrdCore Library in the page I wrote about that. For this exercise, you just have to provide, by other means...

#define ouPLL 5

... if you want to plug the daughter board (or equivalent) into the daughter board socket I was using, the one connected to digital pin 5 of the Arduino.

And, for the "fancy" version of the SmartLED daughter board demonstrator, if you haven't bothered with the NovGrdCore library, you have to provide the following subroutines...

boInHigh(x), where X can be 0,1,2 or 3: Returns "true" or "false", depending on whether a button is pressed. It reads one of four buttons, which one depending on the value you have in x.

makeOuUL(x), where X can be 0 or 1: Makes the Upper Left output high or low, depending on the value you have in x... and some similar routines for UR and LL.

You WILL need the Adafruit_NeoPixel library to use the software below. Obtaining and installing that, if you need help (it isn't hard) is contained within the page I already cited about using WS2812 SmartLEDs.

Arduino code for driving the daughter board

Assuming you are using a NoviceGuard board and the NovGrdCore library, all you need to turn four LEDs "on", one white, one red, one blue, one green (and not too bright!) is...

Really boring.... but "clear"

The following shows you all "the stuff" you need to get the thing working. Well. Showing a static display of four SmartLEDs, one set to white, one to red, one to blue and one to green.

#include <NovGrdCore.h>
#include <Adafruit_NeoPixel.h>
#define bLedSmartLEDStripPin ouPLL//no ; here

Adafruit_NeoPixel SmartLEDStrip=
         NEO_GRB + NEO_KHZ800);
void setup()
//For Adafruit_Neopixel's needs...
SmartLEDStrip.begin();; // Initialize all pixels to 'off'
}//end of setup()

void loop()
}//end of loop()

That's it. Everything you need to generate the display shown in the photo at the top of the page.

There are various "setup" bits. Then the four SmartLEDStrip.setPixelColor... lines, one for each SmartLED.

But the LEDs don't show those colors until the...;

... line executes.


The setPixelColor() commands updates an entry in a buffer in the Arduino's memory; the command sends... exceedingly quickly... a "long" message to the array of smart LEDs. A message boiling down to "LED0, you should be..., LED1, you should be...., etc" (One "you should be" for each smart LED)". (The buffer is set up for you by the SmartLEDStrip.begin()).

More fun!

The following doesn't do anything "clever" with turning the SmartLEDs on and off, or setting their color or brightness.

The whole program is "just" some SmartLEDStrip.setPixelColor... lines, with; thrown in from time to time.

The "cleverness" (such that it is) in this is in the control structures allowing a user to "tell" the Arduino which of several available dynamic patterns should be presented.

The program also uses the basic Arduino loop (and some variables) to step through many stages in three of the four "do this" choices. (Pressing the Upper Left button tells the Arduino just to display a steady mid-bright white, red, blue and green.)


Filename: The "15426" is for 26 Apr 2015, to disambiguate

This is a simple demo for four WS2812 smart LEDs plugged
into input "LL" (lower left) of a NoviceGuard (You make
ONE change in the following to use a different output,
ONE other change to use a different number of WS2812s



***Be sure*** J1 is linked to the UPPER "Ex" pin for this

Vers: 26 Apr 15
Started 26 Apr 15
Simple demo/test program for WS2812s on an Arduino
via a NoviceGuard... see...

(Nothing to do with the WS2812s... )
As usual, the NoviceGuard needs two 10k
(or thereabouts) resistors pulling inputs
inPUR and inPLR high. These may be soldered
to the board, or supplied via restores on
pins, working like a "daughter board".*/

//For NoviceGuard, but not "required" if you do some
//#defines by hand and provide some simple subroutines
#include <NovGrdCore.h>

//For Adafruit_NeoPixel's needs...
#include <Adafruit_NeoPixel.h>
#define bLedSmartLEDStripPin ouPLL//no ; here

Adafruit_NeoPixel SmartLEDStrip=
         NEO_GRB + NEO_KHZ800);
N.B.: In the following creation of an instance of
  the NovGrdCore object, use whatever name you
  like where I have NGC, but is there any reason
  to use anything else? Remember: if you change
  it here, you must also change it in the other
  places it appears.*/
NovGrdCore NGC;

//For this program, not of broader implication...
byte bPattSel;//Pattern select... based on input
       //buttons pressed.
byte bRed;
byte bGreen;
byte bBlue;
word wCycle;
word wCycleSlow;
byte bTmp;
void setup()
/*Various pinMode statement are executed when you
  create the NovGrdCore object (NGC).
REMEMBER, PLEASE: Do not put any pinMode
  statements into your programs while you are
  still using the NoviceGuard, unless you are
  sure, sure, SURE you've been given special
  permission for some reason.*/
//Init various variables...

//For Adafruit_Neopixel's needs...
SmartLEDStrip.begin();; // Initialize all pixels to 'off'

//Optional check on your NovGrdCore library version
//It will appear on serial monitor.
Serial.print("Compiled using version ");
Serial.println("of the NovGrdCore library");
}//end of setup()

void loop()
if (NGC.boInHigh(0))
     {NGC.makeOuUL(0);}//no ; here
      bPattSel=0;}//end of else

if (NGC.boInHigh(1))
     {NGC.makeOuUR(0);}//no ; here
      bPattSel=1;}//end of else

if (NGC.boInHigh(2))
//Don't use ouPLL ("2").... it has the
//  SmartLED array on it.
{}//no ; here
     {bPattSel=2;}//end of else

//The "same" thing, again, to illustrate
//  a more elegant, (but more obscure) way...
if (NGC.boInHigh(3))
  {NGC.makeOu(3,0);}//no ; here
      bPattSel=3;};//end of else

/*SmartLED specific code...
The Case 0 display is the easiest to understand. It is always
"only" a matter of doing some...
statements, and then a;
In the setPixelColor statement, replace CHAN with 0,1,2 or 3 to
select the SmartLED you want. (O:UL, then numbered clockwise around
the square. NOT numbered as other things on NoviceGuard)
The RRR,BBB,GGGs to be replaced by numbers, 0-255

There's nothing particularly brilliant about any of these...
YOU should be able to come up with much more interesting,
and pretty, effects from the Smart LEDs.*/

switch (bPattSel){
case 0:
 break;//End of case 0
 case 1:
  if ((wCycle%48)==0) {wCycleSlow++;};
  if (wCycleSlow==65534){wCycleSlow=0;}
 break;//End of case 1

case 2:
  if ((wCycle%64)==0) {wCycleSlow++;};
  if (wCycleSlow==65534){wCycleSlow=0;}
 break;//End of case 2
 case 3:
  if ((wCycle%768)==0) {wCycleSlow++;};
  if (wCycleSlow==65534){wCycleSlow=0;}
 //End of case 3
};//end of switch/case
if (wCycle>65534) {wCycle=0;};
}//end of loop()

That's it. I hope it fanned your interest in NoviceGuard, or the SmartLEDs, or both!

How to email or write this page's editor, Tom Boyd

Valid HTML 4.01 Transitional Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at Mostly passes, just a few "No attribute" issues, arising from Google code.

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....