Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Digitally controlled 8x RGB LED Light Strip (HCMODU0075) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 631
Post Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Image

Image

This module contains a strip of 8 individually controllable RGB LEDs arranged in a serial (daisy-chain) configuration. Each LEDs red, green, and blue, elements can be individually set to one of 256 intensity settings allowing a over 16 million colour variations. The module also has power and data connection at both ends so that multiple modes 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. We also decided to go one better an allow you to stack multiple the strips in columns to create a full colour message display! See our forum or blog for more information on this library and requirements.

Image
Image showing 8 modules in series. Note: When powering multiple modules at full brightness an external 5V supply may be required.


Image

Model number: HCMODU0075
Supply voltage: 4 to 7V (5V recommended)
LEDs per strip: 8
Max module current: 100mA (approx)
Module length: 54.5mm
Module width: 10.5mm




Image

Input header:
GND.....0V
DIN......Data in
VCC.....Supply input
GND.....0V

Output header:
GND.....0V
DOUT...Data out
VCC.....Supply input
GND.....0V


Image




Image

Code:
/* 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:
/* 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);
}



Code:
/* FILE:    HCWS2812_Message_Display_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 create a message display.
To use this example you will need to connect the LEDs in series (Dout --> Din) and
arrange them in columns of 8 to create your LED array. Connect the Din of the first
LED to digital pin  of your Arduino.

You can create as many columns of 8 LEDs as you like but you will need to edit the
following line in the HCWS2812.h header file:

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

This value must be an multiple of 8 otherwise the print functions will not work

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()
{
  Serial.begin(9600);

  /* Set the fonts R G B colour to white */
  HCWS2812.SetFontFG(100, 100, 100);
  /* Set the fonts R G B background colour to light red */
  HCWS2812.SetBG(20, 0, 0);
}

/* Main program */
void loop()
{
  byte index;
 
  /* Scroll some text with random background colours */
  for(index = 0; index < 160; index++)
  {
    /* Clear the output buffer */
    HCWS2812.ClearBuffer();
    /* Change the fonts background colour every 16 steps */
    if (index % 16 == 0)
      HCWS2812.SetFontBG(random(0,20), random(0,20), random(0,20));
   
    /* Print some text to the output buffer */
    HCWS2812.print("HOBBY COMPONENTS", index);
   
    /* Send the contents of the output buffer to the LEDs */
    HCWS2812.Refresh();
   
    /* Wait a little before moving the text to the next position */
    delay(80); 
  }   
   
  HCWS2812.ClearBuffer(); 
  /* Set the fonts background colour to light green */
  HCWS2812.SetFontBG(0, 20, 0);
 
  /* Scroll an integer number */
  for(index = 0; index < 64; index++)
  {
    HCWS2812.ClearBuffer();
    HCWS2812.print(-1234, index);
    HCWS2812.Refresh();
    delay(80); 
  }


  HCWS2812.ClearBuffer(); 
  /* Set the fonts background colour to light green */
  HCWS2812.SetFontBG(0, 20, 0);
 
  /* Scroll an integer number with a decimal point
     (notice a leading zero is added) */
  for(index = 0; index < 80; index++)
  {
    HCWS2812.ClearBuffer();
    HCWS2812.print(-1234, 4, index);
    HCWS2812.Refresh();
    delay(80); 
  }
}





Image

The library files can be downloaded from github here:

https://github.com/HobbyComponents/HCWS2812

Or directly from this forum:

viewtopic.php?f=58&t=1799


Datasheet:

Attachment:
WS2812.pdf


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


Fri Mar 27, 2015 12:19 pm
Profile

Joined: Thu Mar 13, 2014 12:46 pm
Posts: 23
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Just connected up to a Mini Pro and all the LEDs just come white, I changed the define NUMBEROFLEDS in header file to 8 first.

Any ideas what I may be doing wrong?

Cheers


Wed Apr 08, 2015 9:43 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 620
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
By default the LEDs shouldn't turn on unless they are told to do so. So it would suggest your pro min is sending something to them, just not what is expected. Are you by any chance using the 3.3V version of the pro mini?

As a side note, it's not important for the value of NUMBEROFLEDS to exactly match the amount of LEDs you have. It can be left to a higher number, it's just that by reducing this value you save clock cycles.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Thu Apr 09, 2015 7:28 am
Profile

Joined: Thu Mar 13, 2014 12:46 pm
Posts: 23
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
andrew wrote:
By default the LEDs shouldn't turn on unless they are told to do so. So it would suggest your pro min is sending something to them, just not what is expected. Are you by any chance using the 3.3V version of the pro mini?

As a side note, it's not important for the value of NUMBEROFLEDS to exactly match the amount of LEDs you have. It can be left to a higher number, it's just that by reducing this value you save clock cycles.


My Mini is 5V, I also tried it with my UNO 5V with the same result, I then downloaded an Adafruit library and that works fine, so the Arduino and LED strip are fine.


Thu Apr 09, 2015 12:29 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 620
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Odd, it should work fine with both. Did you try it with the first example (Cylon_Example) in its unaltered form? That sketch should defiantly work.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Thu Apr 09, 2015 2:45 pm
Profile

Joined: Thu Mar 13, 2014 12:46 pm
Posts: 23
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
andrew wrote:
Odd, it should work fine with both. Did you try it with the first example (Cylon_Example) in its unaltered form? That sketch should defiantly work.


Tried both cylon and random examples in their unaltered form and both just turn on all LEDs white...???

I would say I'm doing something wrong but when I load the adafruit examples they work fine.


Thu Apr 09, 2015 6:50 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 620
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Yeah its's a pretty simple setup so not a lot to get wrong. I does sound like a timing issue. The timing constraints of the data signal is very tight and it has to be tuned for the different types of microcontroller on different Arduino boards. I'll try and find some time today to download the library to a clean system and test it but it should work fine. Until then if you still want to use our library one thing you could try is to add the following line to the top of the HCWS2812.h header file:

#define __AVR_ATmega328P__

I've not tested it but it should force it to use the timing for an ATMega328 which is what is on your pro mini and Uno. Also if you could let me know what version of Arduino IDE you are using that would be very helpful thanks.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri Apr 10, 2015 8:24 am
Profile

Joined: Thu Mar 13, 2014 12:46 pm
Posts: 23
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
andrew wrote:
Yeah its's a pretty simple setup so not a lot to get wrong. I does sound like a timing issue. The timing constraints of the data signal is very tight and it has to be tuned for the different types of microcontroller on different Arduino boards. I'll try and find some time today to download the library to a clean system and test it but it should work fine. Until then if you still want to use our library one thing you could try is to add the following line to the top of the HCWS2812.h header file:

#define __AVR_ATmega328P__

I've not tested it but it should force it to use the timing for an ATMega328 which is what is on your pro mini and Uno. Also if you could let me know what version of Arduino IDE you are using that would be very helpful thanks.


Hi,
I added the line at the top of the header file but the same result.

My IDE is 1.6.2.

Cheers


Fri Apr 10, 2015 5:20 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 620
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Yeah something about that version of IDE seems to be screwing up the timings. If I take some of the delays out it works. I won't be able to make a permanent fix until I can get into the office and access to an oscilloscope next Monday. But for now there is a couple of workarounds you can do to get it working. Either use a version 1.0.X of the IDE to compile your code, OR change the following line in the header file:

In the file HCWS2812.h find the following comment:

/* Settings for ATMega328P based Arduino's (Uno, Nano etc..) */

Directly below that is the following line:

#define LOWDELAYHIGH __asm__ __volatile__ ("nop\n nop\n nop\n nop\n")

Change it to:

#define LOWDELAYHIGH __asm__ __volatile__ ("nop\n")


Changing the above line was enough to fix it for me but I'll need to look at it on an oscilloscope to tune it properly. I'll post again when I figure out what about that version of IDE is causing a problem and update the library. Thanks for your help.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Sat Apr 11, 2015 11:36 am
Profile

Joined: Thu Mar 13, 2014 12:46 pm
Posts: 23
Post Re: Digitally controlled 8x RGB LED Light Strip (HCMODU0075)
Thanks, that fixed it.
One other thing I tried was to add a lesser intensity red LED trailing the moving one, but when the LED changed direction the LED at the end flashes green or blue.

Code:
  /* Step forward through each LED */
  for(index = 0; index < NUMBEROFLEDS; index++)
  { 
    HCWS2812.ClearBuffer();
    RGBBuffer[RED][index] = 85;
    RGBBuffer[RED][index-1] = 15;
    HCWS2812.Refresh();
    delay(100);
  }
 
  /* Step backward through each LED */
  for(index = NUMBEROFLEDS; index; index--)
  { 
    HCWS2812.ClearBuffer();
    RGBBuffer[RED][index - 1] = 85;
    RGBBuffer[RED][index] = 15;
    HCWS2812.Refresh();
    delay(100);
  }


Sat Apr 11, 2015 9:06 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 14 posts ]  Go to page 1, 2  Next

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