Reply to topic  [ 4 posts ] 
WeMos D1 Mini WS8212 RGB LED Shield (HCWEMO0008) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:02 pm
Posts: 670
Post WeMos D1 Mini WS8212 RGB LED Shield (HCWEMO0008)
Image




The WeMos WS2812B RGB Shield is a digital full colour (16777216 colour) RGB LED light source. It is specifically designed for the WeMos mini and mini Pro (see item HWEMO0002) ESP8266 based development boards. This shield includes two 8 pin headers (these will require soldering to the module) which will allow it to be easily inserted into the D1 minis headers. To control the LED the shield only requires one digital IO pin (D2).

To make programming this shield from your D1 mini as easy as possible we have updated our HCWS8212 Arduino library to support the WeMos D1 min/Pro and this shield. See below for where to download this library.


Image Image



Image



Specification:

LED Size: 5050
Colours: 16777216
Voltage: 5V



Example Arduino Sketch:

Code:
/* FILE:    HCWS2812_WeMos_WS2812_Shield_Example
   DATE:    30/11/16
   VERSION: 0.1
   AUTHOR:  Andrew Davies

11/03/15 version 0.1: Original version

This example shows how to use the HCWS2812 to control the WS2812 shield for the
WeMos D1 mini and mini Pro boards (HCWEMO0002). The example will cycle the RGB LED
on the shield through the different colours.

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 ESP266WiFi.h library */
#include <ESP8266WiFi.h>

/* 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();

  /* The library requires very precise timing. Therefore WiFi needs to be disabled whilst 
     updating the LEDs to that is doesn't get interrupted. */
  WiFi.mode(WIFI_OFF);

  /* After you have updated the LED WiFi can be turn back on using one of the following modes:
   * WiFi.mode(WIFI_AP);
   * WiFi.mode(WIFI_STA);
   * WiFi.mode(WIFI_AP_STA);
   */
}

void loop()
{

  /* Fade colour from red to green */
  for(int i = 0; i <= 255; i++)
  {
     RGBBuffer[RED][0] = 255 - i;
     RGBBuffer[GREEN][0] = i;
     HCWS2812.Refresh();
     delay(10);
  }

  /* Fade colour from green to blue */
  for(int i = 0; i <= 255; i++)
  {
     RGBBuffer[GREEN][0] = 255 - i;
     RGBBuffer[BLUE][0] = i;
     HCWS2812.Refresh();
     delay(10);
  }

  /* Fade colour from blue to red */
  for(int i = 0; i <= 255; i++)
  {
     RGBBuffer[BLUE][0] = 255 - i;
     RGBBuffer[RED][0] = i;
     HCWS2812.Refresh();
     delay(10);
  }

}




Image

Attachment:
HCWEMO0008_Schematic.pdf



HCWS8212 Arduino library can be downloaded from the software section of our support forum here: viewtopic.php?f=58&t=1799



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 no 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.


Wed Nov 30, 2016 4:18 pm
Profile

Joined: Wed May 24, 2017 7:52 pm
Posts: 2
Post Re: WeMos D1 Mini WS8212 RGB LED Shield (HCWEMO0008)
Hi

I use your library with wemos d1 mini and rgb shield shown your picture.

I just need set the led color RGB http://www.colorspire.com/rgb-color-wheel shown this site.

Red : 255,0,0
Blue :0,0,255
Yellow :255,255,0

But your librarr does not responde like that.

Code:
  HCWS2812.SetBG(0, 0, 0);
  HCWS2812.ClearBuffer();
  RGBBuffer[RED][0] = 0 ;
  RGBBuffer[GREEN][0] =0;
  RGBBuffer[BLUE][0] = 0;
  HCWS2812.Refresh();

  RGBBuffer[RED][0]   = r ;
  RGBBuffer[BLUE][0]  = g;
  RGBBuffer[GREEN][0] = b;
  HCWS2812.Refresh();



Best ragards.


Wed May 24, 2017 7:56 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 706
Post Re: WeMos D1 Mini WS8212 RGB LED Shield (HCWEMO0008)
It should work fine with the RGB values given by that website but I have a few comments on your posted code:

Code:
HCWS2812.SetBG(0, 0, 0);
HCWS2812.ClearBuffer();
RGBBuffer[RED][0] = 0 ;
RGBBuffer[GREEN][0] =0;
RGBBuffer[BLUE][0] = 0;
HCWS2812.Refresh();

RGBBuffer[RED][0] = r ;
RGBBuffer[BLUE][0] = g;
RGBBuffer[GREEN][0] = b;
HCWS2812.Refresh();



For lines 3,4,5, & 6 your setting the RGB elements of the LED to 0 (off) but then immediately setting them to another value in lines 7,8,9, & 10. So lines 3 to 6 don't seem to be doing anything and you could just delete them.

For lines 7,8, & 9 I don't know what the 'r', 'g', & 'b' represent. I.e. are they variables set in a part of your sketch you have not posted, or are they just where you placing the R, G, & B values taken from the website? Notice that you are setting the BLUE element to g and the GREEN element to b. Could that possibly be your issue?

If not can you post an example of your sketch and what colour you expect to see.

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


Thu May 25, 2017 9:05 am
Profile

Joined: Wed May 24, 2017 7:52 pm
Posts: 2
Post Re: WeMos D1 Mini WS8212 RGB LED Shield (HCWEMO0008)
Hi

You are correct. Because i canged my code (Blue-g,Green-b) response is diffrent but the reason is hardware problem. I change rgb shield with new one its work well.

RGBBuffer[BLUE][0] = g;
RGBBuffer[GREEN][0] = b;

My working sample below...

Best regards.

Using browser to set http://192...../rgb?r=102&g=176&b=50 ----green

-----------------------------------------------



#include <ESP8266WiFi.h>
#include "HCWS2812.h"
#include <ESP8266WebServer.h>
WiFiServer server(80);
ESP8266WebServer serverrun(80);
HCWS2812 HCWS2812;
void setup()
{
Serial.begin(115200);
/* Set the R,G,B background colours to zero */
HCWS2812.SetBG(0, 0, 0);
/* Clear the output buffer */
HCWS2812.ClearBuffer();

int i;
i=0;
//WiFi.config(addr, gateway, subnet);
WiFi.begin("TANDOGAN", "a123456789");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
++i;
if (i>100 ) exit;
}
delay(100);
Serial.println(WiFi.localIP());
WiFi.mode(WIFI_STA);

serverrun.on("/rgb", []() {
String r_s=serverrun.arg("r");
String g_s=serverrun.arg("g");
String b_s=serverrun.arg("b");
Serial.println("rgb " + r_s + "," + g_s + "," + b_s );
rgbset(r_s.toInt(),g_s.toInt(),b_s.toInt());

serverrun.send(200, "text/html", "ok");
delay(1000);
});
serverrun.begin();
}

void loop()
{
serverrun.handleClient();
}

void rgbset(int r,int g,int b)
{
HCWS2812.SetBG(0, 0, 0);
RGBBuffer[RED][0] = r ;
RGBBuffer[BLUE][0] = b;
RGBBuffer[GREEN][0] = g;
HCWS2812.Refresh();
/* Clear the output buffer */
HCWS2812.ClearBuffer();

RGBBuffer[RED][0] = r ;
RGBBuffer[BLUE][0] = b;
RGBBuffer[GREEN][0] = g;
HCWS2812.Refresh();
}


Thu May 25, 2017 2:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

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