element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Ralph Yamamoto's Blog NeoPixel Dice
  • Blogs
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 26 May 2022 9:26 PM Date Created
  • Views 1349 views
  • Likes 12 likes
  • Comments 5 comments
  • rp2040 feather
  • neopixel dice
  • neopixel
  • neopixel matrix
  • rp2040
Related
Recommended

NeoPixel Dice

ralphjy
ralphjy
26 May 2022

I was somewhat inspired by a post by  scottiebabe - Electronic Die to look at square NeoPixel Arrays.  I've used NeoPixels in PCB strips and rings and also flexible strips before, but haven't tried square arrays.  It seems the common square matrix PCB sizes are 4x4 or 8x8 using WS2812B RGB LEDs.  

I found an interesting option on Amazon - ALITOVE 100pcs WS2812B Addressable 5050 Smart RGB LED Pixels.  It is a 10x10 matrix of RGB LEDs that are physically, but not electrically connected  That supposedly would allow you to create any square or rectangular matrix smaller than 10x10.  Bad news is that you need to do all the wiring (3pins between the LEDs).  For $15.99, I thought I would give it a try.

Here's what it looks like - just under 100mm square:

And the pads that need to be connected on the back:

I cut out a 3x3 section to make an electronic dice face.  The PCB is pre-scored between RGB LEDs, but I learned the hard way that trying to cut a square section out with diagonal cutters puts force in the wrong places and will cause adjacent score lines to break.  It's a little to hard to cut with an X-ACTO knife.  I think I'll need to appropriate a rotary cutter from my wife for future cutting.

I used the QWIIC port on the RP2040 Feather to connect to the array.  Connecting the LED pads wasn't too bad using 28AWG wire.

Here's a quick video:

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

The code is brute force, I probably need to improve it to use in a project.

NeoPixel_Array_Dice.ino

// NeoPixel Array simple sketch (c) 2022 ralphjy
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library

#include <Adafruit_NeoPixel.h>

// Which pin is connected to the NeoPixels?
#define PIN        2 // QWIIC connector SDA

// How many NeoPixels?
#define NUMPIXELS 9 // 3x3 array size

// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define DELAYVAL 1000 // Time (in milliseconds) to pause between pixels

void setup() {
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'

  for (int a = 1; a < 7; a++) {
    diceNumber(a);
    delay(DELAYVAL); // Pause before next pass through loop    
  }
}

void diceNumber(int n) 
{
  switch (n) {
    case 0:
      pixels.setPixelColor(0, pixels.Color(0, 0, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 0, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 0, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 0, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 0, 0));
      pixels.show();
      break;
    case 1:
      pixels.setPixelColor(0, pixels.Color(0, 0, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 0, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 20, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 0, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 0, 0));
      pixels.show();
      break;
    case 2:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 0, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 0, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 0, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 20, 0));
      pixels.show();
      break;
    case 3:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 0, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 20, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 0, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 20, 0));
      pixels.show();
      break;
    case 4:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 20, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 0, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 20, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 20, 0));
      pixels.show();
      break;
    case 5:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 20, 0));
      pixels.setPixelColor(3, pixels.Color(0, 0, 0));
      pixels.setPixelColor(4, pixels.Color(0, 20, 0));
      pixels.setPixelColor(5, pixels.Color(0, 0, 0));
      pixels.setPixelColor(6, pixels.Color(0, 20, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 20, 0));
      pixels.show();
      break;
    case 6:
      pixels.setPixelColor(0, pixels.Color(0, 20, 0));
      pixels.setPixelColor(1, pixels.Color(0, 0, 0));
      pixels.setPixelColor(2, pixels.Color(0, 20, 0));
      pixels.setPixelColor(3, pixels.Color(0, 20, 0));
      pixels.setPixelColor(4, pixels.Color(0, 0, 0));
      pixels.setPixelColor(5, pixels.Color(0, 20, 0));
      pixels.setPixelColor(6, pixels.Color(0, 20, 0));
      pixels.setPixelColor(7, pixels.Color(0, 0, 0));
      pixels.setPixelColor(8, pixels.Color(0, 20, 0));
      pixels.show();
      break;      
  }
}

Anonymous
  • neilk
    neilk 1 month ago

    Neat! must have a play with some neopixels

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • scottiebabe
    scottiebabe 1 month ago

    Pink feather spotted!! This looks soo good! I really like the dimensions your 3x3 matrix turned out to be 3cm x 3cm (I believe) the first discrete led version I made felt a tad oversized, especially if I had made it into a cube. I suppose something like a seed xiao could easily fit inside a 3x3x3cm cube

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • javagoza
    javagoza 1 month ago

    Thanks for sharing. I am new to neopixels. How is power consumption calculated?

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • robogary
    robogary 1 month ago

    looks great

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • genebren
    genebren 1 month ago

    Fun little project.  The NeoPixel is a neat concept.  I recently started using them in a product that I build.  I had been using a three channel LED dimmer/driver to drive two RGB LEDs, but the dimmer/driver part is no longer in stock (darn shortages), so I pivoted over to discrete NeoPixel which are working out really well.  Great brightness, and great color balance.

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube