Hi guys, today we are going to discuss, interfacing of neo pixel led through Nodemcu (ESP8266-12E). Neo pixel is addressable led; we can program to display any number/name in any color using microcontroller. Neo pixel came in different smd packages, here we are using Ws2812b-5050 mini RGB.

mini_WS2812B-Addressable-RGB-LED-pinout-diagram.jpg

This mini led has voltage ratings: 3.0v to 5.5volts @16mA (for each Led). Our Nodemcu has 3.3-volt regulator, to drive all the Led’s properly.

Making 7 segment display using neo pixel led:

Step 1:

Here, I do all the power connections in parallel and all the Data connection in series. Using the 7-segment display method, and connect all the Led’s in proper format (As in diagram).

ice_screenshot_20211203-230331.png

About JLCPCB:

SMT service provided by JLCPCB is terrific. They are providing the best quality in very low price. Also support millions of components and footprints. Cost of soldering, assembling and panelizing the pcb is lower than other manufacturers. That’s why I choose JLCPCB for my different projects.

ice_screenshot_20211226-210213.png

I had a very great experience with this assembly service, first I want to say that all the component are original and aligned very well on the PCB as designed. Quality of solder and solder joints are very decent. All the components are in working condition, concluding all these points I think it worth. I got these panels in a very low cost from JLCPCB.https://jlcpcb.com/IAT

mini_20211226_170626.jpg

JLCPCB is also providing new user coupons and sign-up rewards of up to $30. So, check them out from here. Register using this link to get Free PCB assembly service coupons. Get your 2layer to 6-layer PCB’s just in $2, stencil and PCB assembly service in just $7.

More Projects:

1) 8X8 RGB Neo pixel Matrix using ws2812 led

2) 100W audio amplifier using Tda7294

3) Make your own Arduino Nano compatible board

Think you enjoy my work, stay tuned. Follow us on Instagram (sagar_saini_7294) and hackaday.

Step 2:

Each of the segment has 2 Led’s and One whole panel has 14 Led’s in total. We need 4 panels to display time (2 for Hours, 2 for minutes) for the future Clock project. Two more panels can be connected, to display seconds/any other values like Temperature.

3d.png

Always connect Dout of first panel to Din of second.

Step 3:

Now, Turn Your schematics into PCB and arrange the Led’s in the format of general 7 segment display. Here you can get an example of this.

ice_screenshot_20211226-214133.png

Step 4:

Making a beautiful looking PCB is equally important. So, I designed the PCB, started with a rectangular board outline then adding different type of board cut-out to PCB. Finally, this image may show my work to you.

op_AdobeCreativeCloudExpress.gif

Step 5:

Make connection of all the nets and tracks, build the copper area using GND connections for top and bottom layer. Connections can be done using Auto route/ EasyEDA is the best software for this type of work. And JLCPCB is the best PCB manufacturer for low cost and quality.

Circuit Diagram:

Schematic_WS2812RGB_2021-12-03 (1).png

Connection with Nodemcu:

NEOPIXEL.png

SMT Assembly Service:

Instead of ordering simple PCB’s from JLCPCB, I tried SMT assembly service in just a price of $7 + component charges. Soldering and placing components on PCB’s are done in this process. So, I just have to unbox the PCB and use them directly.

mini_20211226_170541.jpg

Here is the received package and PCB’s. Quality of PCB’s are very good and every component is soldered on its exact place. Have a look on the SMT service, try this and get coupons of worth $30 on first Sign-up using our link.

PCB and Circuit Download:

Download all the important files from here.

Testing with different examples:

1) Counter:

Up-down counter is there in the code, We can change the counting 0 to 999 and delay between each count.

/disp_CountUP(500, 450);       // Count numbers in Ascending order  (NUMBER, DelayTime)
//  disp_CountDOWN(500, 250);     // Count numbers in Descending order (NUMBER, DelayTime)
Untitled__2__AdobeCreativeCloudExpress.gif

2) To display Numbers:

Numbers displayed on each segment are of same color at a time. In the code color can be changed using the function.

RGB:

Red(brightness,0,0)

Green(0,brightness,0)

Blue(0,0,brightness)

My_Video10_AdobeCreativeCloudExpress.gif

3) Showing Animations:

Each pixel contains 2 led so animations can be drawn in this format, also the costom color can be obtained by making any two from RGB to High.

example:

Pink: RGB = (brightness,brightness,0)

Untitled__1__AdobeCreativeCloudExpress.gif

Code:

This code is modified to display Animations and numbers on these 7 segment panels. Just Uncomment the portion of code, you want to use.

Example: To display numbers

//disp_Seg(200);                // Cycle through all segments        (DelayTime)
  disp_Digits(1000);            // Show digits from 0-9              (DelayTime)
  //disp_Animation();             // Show some Animations with the segments
 //disp_CountUP(500, 450);       // Count numbers in Ascending order  (NUMBER, DelayTime)
//  disp_CountDOWN(500, 250);     // Count numbers in Descending order (NUMBER, DelayTime)

Main test code

#include <Adafruit_NeoPixel.h>

#define PIXELS_PER_SEGMENT  2     // Number of LEDs in each Segment
#define PIXELS_DIGITS       4     // Number of connected Digits 
#define PIXELS_PIN          2     // GPIO Pin

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXELS_PER_SEGMENT * 7 * PIXELS_DIGITS, PIXELS_PIN, NEO_GRB + NEO_KHZ800);

//Pixel Arrangement
/*
          a
        f   b
          g
        e   c
          d
*/

// Segment array
byte segments[7] = {
  //abcdefg
  0b0000001,     // Segment g
  0b0000100,     // Segment e
  0b0001000,     // Segment d
  0b0010000,     // Segment c
  0b0100000,     // Segment b
  0b1000000,     // Segment a
  0b0000010     // Segment f
};

//Digits array
byte digits[10] = {
  //abcdefg
  0b1111110,     // 0
  0b0110000,     // 1
  0b1101101,     // 2
  0b1111001,     // 3
  0b0110011,     // 4
  0b1011011,     // 5
  0b1011111,     // 6
  0b1110000,     // 7
  0b1111111,     // 8
  0b1110011      // 9
};

//Clear all the Pixels
void clearDisplay() {
  for (int i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0));
  }
  strip.show();
}

void setup() {
  strip.begin();
}

void loop() {
  //disp_Seg(200);                // Cycle through all segments        (DelayTime)
  disp_Digits(1000);            // Show digits from 0-9              (DelayTime)
  //disp_Animation();             // Show some Animations with the segments
 //disp_CountUP(500, 450);       // Count numbers in Ascending order  (NUMBER, DelayTime)
//  disp_CountDOWN(500, 250);     // Count numbers in Descending order (NUMBER, DelayTime)
}

void disp_Seg(int wait) {
  clearDisplay();
  for (int d = 0; d < 5; d++) {
    for (int i = 6; i > 0; i--) {
      for (int n = 0; n < PIXELS_DIGITS; n++) {
        writeSegment(n, i);
      }
      strip.show();
      delay(wait);
    }
  }
}

void disp_Digits(int wait) {
  clearDisplay();
  for (int i = 0; i < 10; i++) {
    for (int n = 0; n < PIXELS_DIGITS; n++) {
      writeDigit(n, i);
    }
    strip.show();
    delay(wait);
  }
}

void disp_CountUP(int num, int wait) {
  clearDisplay();
  for (int i = 0; i <= num; i++) {
    writeDigit(0, (i / 100) % 10);
    writeDigit(1, (i / 10) % 10);
    writeDigit(2, (i / 1) % 10);
    strip.show();
    delay(wait);
  }
}

void disp_CountDOWN(int num, int wait) {
  clearDisplay();
  for (int i = num; i >= 0; i--) {
    writeDigit(0, (i / 100) % 10);
    writeDigit(1, (i / 10) % 10);
    writeDigit(2, (i / 1) % 10);
    strip.show();
    delay(wait);
  }
}

void disp_Animation() {
  clearDisplay();
  //UP-DOWN
  for (int i = 0; i < 7; i++) {
    for (int n = 0; n < PIXELS_DIGITS; n++) writeSegment(n, 5);
    strip.show();
    delay(100);
    for (int n = 0; n < PIXELS_DIGITS; n++) writeSegment(n, 0);
    strip.show();
    delay(100);
    for (int n = 0; n < PIXELS_DIGITS; n++) writeSegment(n, 2);
    strip.show();
    delay(100);
    for (int n = 0; n < PIXELS_DIGITS; n++) writeSegment(n, 0);
    strip.show();
    delay(100);
    for (int n = 0; n < PIXELS_DIGITS; n++) writeSegment(n, 5);
    strip.show();
    delay(100);
  }
  //LEFT-RIGHT
  for (int i = 0; i < 5; i++) {
    for (int n = 0; n < PIXELS_DIGITS; n++) {
      writeSegment(n, 6);
      strip.show();
      delay(150);
    }
    for (int n = PIXELS_DIGITS - 1; n >= 0; n--) {
      writeSegment(n, 3);
      strip.show();
      delay(150);
    }
    clearDisplay();
    for (int n = 0; n < PIXELS_DIGITS; n++) {
      writeSegment(n, 1);
      strip.show();
      delay(150);
    }
    for (int n = PIXELS_DIGITS - 1; n >= 0; n--) {
      writeSegment(n, 4);
      strip.show();
      delay(150);
    }
    clearDisplay();
  }
  //ZIG-ZAG
  for (int i = 0; i < 5; i++) {
    for (int n = 0; n < PIXELS_DIGITS; n++) {
      writeSegment(n, 6);
      strip.show();
      delay(125);
      clearDisplay();
      writeSegment(n, 1);
      strip.show();
      delay(125);
      clearDisplay();
      writeSegment(n, 4);
      strip.show();
      delay(125);
      clearDisplay();
      writeSegment(n, 3);
      strip.show();
      delay(125);
      clearDisplay();
    }
  }
}

void writeDigit(int index, int val) {
  byte digit = digits[val];
  for (int i = 6; i >= 0; i--) {
    int offset = index * (PIXELS_PER_SEGMENT * 7) + i * PIXELS_PER_SEGMENT;
    uint32_t color;
    if (digit & 0x01 != 0) {
      if (val == 1) color = strip.Color(50, 0,  0);
      if (val == 2) color = strip.Color(50, 50, 0);
      if (val == 3) color = strip.Color(50, 0, 50);
      if (val == 4) color = strip.Color(0, 50,  0);
      if (val == 5) color = strip.Color(0, 50, 50);
      if (val == 6) color = strip.Color(0,  0, 50);
      if (val == 7) color = strip.Color(50, 25, 0);
      if (val == 8) color = strip.Color(25, 5, 75);
      if (val == 9) color = strip.Color(75, 25, 5);
      if (val == 0) color = strip.Color(5, 75, 25);
    }
    else
      color = strip.Color(0, 0, 0);

    for (int j = offset; j < offset + PIXELS_PER_SEGMENT; j++) {
      strip.setPixelColor(j, color);
    }
    digit = digit >> 1;
  }
}

void writeSegment(int index, int val) {
  byte seg = segments[val];
  for (int i = 6; i >= 0; i--) {
    int offset = index * (PIXELS_PER_SEGMENT * 7) + i * PIXELS_PER_SEGMENT;
    uint32_t color;
    if (seg & 0x01 != 0) {
      if (val == 0) color = strip.Color(50, 0, 0);
      if (val == 1) color = strip.Color(0, 50, 50);
      if (val == 2) color = strip.Color(0, 50, 0);
      if (val == 3) color = strip.Color(50, 0, 50);
      if (val == 4) color = strip.Color(50, 50, 50);
      if (val == 5) color = strip.Color(0, 0, 50);
      if (val == 6) color = strip.Color(50, 50, 0);
    }
    else
      color = strip.Color(0, 0, 0);

    for (int j = offset; j < offset + PIXELS_PER_SEGMENT; j++) {
      strip.setPixelColor(j, color);
    }
    seg = seg >> 1;
  }
}

About JLCPCB:

SMT service provided by JLCPCB is terrific. They are providing the best quality in very low price. Also support millions of components and footprints. Cost of soldering, assembling and panelizing the pcb is lower than other manufacturers. That’s why I choose JLCPCB for my different projects.

ice_screenshot_20211226-210213.png

I had a very great experience with this assembly service, first I want to say that all the component are original and aligned very well on the PCB as designed. Quality of solder and solder joints are very decent. All the components are in working condition, concluding all these points I think it worth. I got these panels in a very low cost from JLCPCB.https://jlcpcb.com/IAT

mini_20211226_170626.jpg

JLCPCB is also providing new user coupons and sign-up rewards of up to $30. So, check them out from here. Register using this link to get Free PCB assembly service coupons. Get your 2layer to 6-layer PCB’s just in $2, stencil and PCB assembly service in just $7.

More Projects:

1) 8X8 RGB Neo pixel Matrix using ws2812 led

2) 100W audio amplifier using Tda7294

3) Make your own Arduino Nano compatible board

Think you enjoy my work, stay tuned. Follow us on Instagram (sagar_saini_7294) and hackaday.