Reply to topic  [ 1 post ] 
66mm WS2812B 24 RGB LED Ring (HCMODU0128) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 713
Post 66mm WS2812B 24 RGB LED Ring (HCMODU0128)
Image





This 66mm module contains a strip of 24 individually controllable RGB LEDs arranged in a circular serial configuration. Each LED has seperatly controllable red, green, and blue, elements which can be individually set to one of 256 different intensity settings, allowing over 16 million colour variations. The module also has power and data connections at both ends of the chain so that multiple modules can be connected together whilst still only requiring one digital pin to drive them.

What's more, to make controlling these LED's from an Arduino as simple as possible we have written our own exclusive library what will handle all the complicated bits. See bottom of this post or our blog for more information on this library and requirements.

Image Image



Image

Model number: HCMODU0128
Supply voltage: 4 to 7V (5V recommended)
LEDs per ring: 16
Max module current: 750mA (approx)
Module diameter: 45mm




Image





Image

Code:
/* FILE:    HCWS2812_Colour_Wheel
   DATE:    26/02/18
   VERSION: 0.1
   AUTHOR:  Andrew Davies

26/02/18 version 0.1: Original version

This is an example of how to use the HCWS2812 library to control one or more
RGB LEDS. The example will set each LED to a random colour.

To use this example connect one or more LEDs in series (Dout --> Din) and connect
the first LED's Din pin to digital pin 8 of your Arduino.

By default the library is set to control 200 LEDs. You can change this by editing the
following line in the HCWS2812.h header file:

#define NUMBEROFLEDS 200 <--- Change this number to match the number of LEDS connected


You can download the library from the software section of our support forum here:
http://forum.hobbycomponents.com/viewforum.php?f=58

Or from Github here:
https://github.com/HobbyComponents/HCWS2812


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/

/* Include the HCWS2812 library */
#include "HCWS2812.h"

/* Create an instance of the library */
HCWS2812 HCWS2812;

/* Speed at which each LED fades.  The lower the value the slower the fade speed */
#define FADESPEED 16

/* Amount of time in ms that each LED is illuminated before moving on to the next */
#define STEPSPEED 50


/* Set starting indexes for each colour. Remember to edit to NUMBEROFLEDS value in the
 *  HCWS2812.h file to match your module! */
byte RedIndex = 0;
byte GreenIndex = NUMBEROFLEDS / 3 * 1;
byte BlueIndex = NUMBEROFLEDS / 3 * 2;

void setup()
{
  /* Set the R,G,B background colours to zero */
  HCWS2812.SetBG(0, 0, 0);
  /* Clear the output buffer */
  HCWS2812.ClearBuffer();
}


/* Main program */
void loop()
{
  /* Fade each illuminated LED */
  for(int index = 0; index < NUMBEROFLEDS; index++)
  { 
    if(RGBBuffer[RED][index] >= FADESPEED)
      RGBBuffer[RED][index] -= FADESPEED;
    else
      RGBBuffer[RED][index] = 0;

    if(RGBBuffer[GREEN][index] >= FADESPEED)
      RGBBuffer[GREEN][index] -= FADESPEED;
    else
      RGBBuffer[GREEN][index] = 0;

    if(RGBBuffer[BLUE][index] >= FADESPEED)
      RGBBuffer[BLUE][index] -= FADESPEED;
    else
      RGBBuffer[BLUE][index] = 0;
  }


  /* Illuminate the next LED for each colour */
  RGBBuffer[RED][RedIndex] = 255;
  RGBBuffer[GREEN][GreenIndex] = 255;
  RGBBuffer[BLUE][BlueIndex] = 255;
 
 
  /* Move LED index to next LED */
  RedIndex++;
  if(RedIndex >= NUMBEROFLEDS)
    RedIndex = 0;

  GreenIndex++;
  if(GreenIndex >= NUMBEROFLEDS)
    GreenIndex = 0;

  BlueIndex++;
  if(BlueIndex >= NUMBEROFLEDS)
    BlueIndex = 0;


  /* Update the module */
  HCWS2812.Refresh();
 
  /* Wait a little before moving on to the next LED */
  delay(STEPSPEED);
}





Image

The library files can be downloaded from github here:

https://github.com/HobbyComponents/HCWS2812

Or directly from this forum:

http://forum.hobbycomponents.com/viewtopic.php?f=58&t=1799


Datasheet:
Attachment:
WS2812.pdf






Disclaimer: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.


You do not have the required permissions to view the files attached to this post.


Mon Feb 26, 2018 3:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD