Flexible Digitally Controlled RGB LED strips (HCOPTO0028)

LCD, TFT, OLED, LED modules
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

Flexible Digitally Controlled RGB LED strips (HCOPTO0028)

Post by admin » Fri Mar 27, 2015 2:31 pm

Image

Image

A flexible full colour RGB LED light strip (HCOPTO0028). Each LED within the strip can be individually controlled to display any one of over 16 million colours. Each LED is connected in a serial chain meaning that each LED can be controlled with only one digital pin on a microcontroller. The strips are based on the WS2812 addressable RGB LEDs and are sold in with 30 LED strips or 5 meter reels.

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 our forum or blog for more information on this library and requirements.

Image


Image

Product code: HCOPTO0028
Working voltage: 5V
Max current: 60mA per LED
Length per 30 LED strip: 50cm
Length per reel: 500cm



Image

+5V.......5V Supply
DI..........Serial data in
DO.........Serial data out
GND.......0V



Image



Image

Code: Select all

/* FILE:    HCWS2812_Cylon_Example
   DATE:    26/03/15
   VERSION: 0.1
   AUTHOR:  Andrew Davies

11/03/15 version 0.1: Original version

This is an example of how to use the HCMAX7219 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 100 LEDs. You can change this by editing the
following line in the MCMAX7219.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;

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() 
{
  int index;
  
  /* Step forward through each LED */
  for(index = 0; index < NUMBEROFLEDS; index++)
  {  
    HCWS2812.ClearBuffer();
    RGBBuffer[RED][index] = 255;
    HCWS2812.Refresh();
    delay(100);
  }
  
  /* Step backward through each LED */
  for(index = NUMBEROFLEDS; index; index--)
  {  
    HCWS2812.ClearBuffer();
    RGBBuffer[RED][index - 1] = 255;
    HCWS2812.Refresh();
    delay(100);
  }
}

Code: Select all

/* FILE:    HCWS2812_Random_Example
   DATE:    26/03/15
   VERSION: 0.1
   AUTHOR:  Andrew Davies

11/03/15 version 0.1: Original version

This is an example of how to use the HCMAX7219 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 100 LEDs. You can change this by editing the
following line in the MCMAX7219.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;

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


void loop() 
{
  int index;
  
  /* Fill the output buffer with random colours */
  for(index = 0; index < NUMBEROFLEDS; index++)
  {  
    RGBBuffer[RED][index] = random(0,255);
    RGBBuffer[GREEN][index] = random(0,255);
    RGBBuffer[BLUE][index] = random(0,255);
  }
  
  /* Send the output buffer to the LEDs */
  HCWS2812.Refresh();
  
  /* Wait a moment before doing it again */
  delay(100);
}



Image

The library files can be downloaded from github here:

https://github.com/HobbyComponents/HCWS2812

Or directly from this forum:

http://forum.hobbycomponents.com/viewto ... =58&t=1799


Datasheet:
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.

RogerL
Posts: 9
Joined: Mon Apr 14, 2014 7:56 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by RogerL » Sun Apr 12, 2015 9:31 am

Both the shop description and the above post state that the length of a 30 LED strip is 50mm. Are they really this small?

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Mon Apr 13, 2015 9:25 am

That's a typo. It should be 50cm not 50mm. I've corrected it in both places. Thanks.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

phillip75
Posts: 1
Joined: Fri Jul 17, 2015 6:33 am

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by phillip75 » Sun Jul 19, 2015 2:36 am

I'm having some issues setting up my [LINK REMOVED BY ADMIN]. I downloaded the library and uploaded the code to my Arduino Mega with no problems. I then connected the LED strip to PIN 12, Ground and 5V on the Arduino. Upon connecting and providing power, I noticed a few random LEDs blinking for a split second, then everything went dark and nothing else happened. The same random blink happened whenever I plugged the strip to Arduino's 5V.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Sun Jul 19, 2015 2:23 pm

I then connected the LED strip to PIN 12, Ground and 5V on the Arduino
The Din of the strip needs to be connected to digital pin 8 on your Arduino.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

XKSteve
Posts: 1
Joined: Mon Apr 14, 2014 6:10 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by XKSteve » Tue Apr 05, 2016 6:32 pm

Hi, Has anyone tried running the HCOPTO0028 strip on a ATTiny85 such as found on the Adafruit trinket? I am guessing that the library HCWS2812.h will need to have the port modified from B0 (D8/pin14 on the 328p) to B4 (D4/pin5 (QFN chip)) if CLK is important, along with maximum driven LEDs value (although I nothing about writing library stuff) or can you just hook up to Digital pin 0 (Port B0-Pin11 QFN chip) instead of Digital pin 8 if not. Reason I ask is I have a small project I want to use the LEDs in and haven't the space to fit a 328p, which would also be over kill, as I need only the LED output pin and no other I/O.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Thu Apr 07, 2016 12:24 pm

Although I can't say for sure without doing some sums, I think it is unlikely that a Tiny85 would be up to the job. The problem is the HCWS2812 requires very precise timings on the data signal (they must be with +/- 150ns if I remember correctly, that's 0.00000015s). This is just about doable on the ATMega328/2650/32u4 devices this library was written for but at best an ATTiny85 will only run at half the clock rate of these devices and I think it just wouldn't be fast enough to generate the data signals within the timing constraints.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Sat Jul 22, 2017 9:27 am

I'm not able to test this right now but can you try changing it from:

Code: Select all

#define DOUT_PIN D2 
to:

Code: Select all

#define DOUT_PIN 2
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Sat Aug 05, 2017 9:58 am

I think i see the problem. Can you try the following:

In the HCWS2812.h header file find the following lines....

Code: Select all

#if defined (ESP8266)
#define DOUT_HIGH GPOS = 1<<4
#define DOUT_LOW GPOC = 1<<4
...and change them to:

Code: Select all

#if defined (ESP8266)
#define DOUT_HIGH GPOS = 1<<2
#define DOUT_LOW GPOC = 1<<2
If you could let me know if this fixes your problem i'll get an update made to the library.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Flexible Digitally Controlled RGB LED strips (HCOPTO002

Post by andrew » Wed Aug 09, 2017 2:31 pm

Thanks for confirming it works. The library was updated to work with the WeMos boards which are also ESP8266 based. However it looks like they may use slightly different core files compared to the ones used by the Huzzah Feather. Hence why it complies ok for one and not the other. I'll get the library updated to work with both as soon as possible.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “Display”