3060 views|24 replies

3386

Posts

0

Resources
The OP
 

[Hua Diao Experience] 19 Hezhou ESP32_C3 lights up WS2812B hard screen [Copy link]

 

I have a 64-bit and a 256-bit WS2812B hard screen, and now I try to light them up.

This post is from DIY/Open Source Hardware

Latest reply

I also bought a Hezhou C3 at that time, but I haven't played it yet, so I'd like to learn it first.   Details Published on 2022-7-12 11:41
 

3386

Posts

0

Resources
2
 

Main features of WS2812
● Intelligent reverse connection protection, reverse connection of power supply will not damage IC.
● IC control circuit and LED point light source share a power supply.
● Control circuit and RGB chip are integrated in a 5050 package component to form a complete externally controlled pixel.
● Built-in signal shaping circuit, any pixel receives the signal and then outputs it after waveform shaping, ensuring that line waveform distortion will not accumulate.
● Built-in power-on reset and power-off reset circuits.
● The three primary colors of each pixel can achieve 256 levels of brightness display, complete 16777216 colors of true color display, and the scanning frequency is not less than 400Hz/s.
● Serial cascade interface, which can complete data reception and decoding through a signal line.
● No circuit needs to be added when the transmission distance between any two points does not exceed 5 meters.
● When the refresh rate is 30 frames/second, the number of cascades is not less than 1024 points.
● The data transmission speed can reach 800Kbps.
● The color of light is highly consistent and cost-effective.

This post is from DIY/Open Source Hardware
 
 

3386

Posts

0

Resources
3
 

WS2812 module electrical schematic

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
4
 

The Hezhou CORE ESP32-C3 core board is a development board designed based on the Espressif ESP32-C3 chip. The size is only 21mm×51mm, the board edge adopts a stamp hole design, and the onboard Wi-Fi/BLE antenna is convenient for developers to use in different scenarios. The core board supports UART, GPIO, SPI, I2C, ADC, PWM and other interfaces, which can be selected according to actual needs.

1 SPI FLASH, 4MB onboard, supports up to 16MB
2 UART interfaces, UART0~UART1, of which the download port is UART0
6 12-bit ADC, maximum sampling rate 100KSPS
1 low-speed SPI interface, supports master mode
1 IIC controller
4 PWM interfaces
15 GPIO external pins, reusable
2 SMD LED indicators
1 reset button + 1 BOOT button
1 USB to TTL download and debug port
2.4G PCB onboard antenna

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
5
 

Open Arduino IDE - Tools - Manage Libraries, search for Adafruit NeoPixel, and install it.

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
6
 

[Hua Diao Experience] 19 Hezhou ESP32_C3 lights up WS2812B hard screen
experimental program 1: 64-bit green floating light

/*
  【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  实验程序一:64位绿色上漂灯
*/

#include <Adafruit_NeoPixel.h>

#define PIN 9
#define MAX_LED 64

int val = 0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );

void setup() {
  strip.setBrightness(150);
  strip.begin();
  strip.show();
}

void loop() {
  uint8_t i, a = 0;
  uint32_t color = strip.Color(160, 10, 10);
  while (a < 64)
  {
    for (i = 0; i < 64; i++)
    {
      if (i == a) strip.setPixelColor(i, color);
      else strip.setPixelColor(i, 0);
    }
    strip.show();
    delay(6);
    a++;
  }
}

This post is from DIY/Open Source Hardware
 
 
 

174

Posts

1

Resources
7
 

I also bought a Hezhou C3 at that time, but I haven't played it yet, so I'd like to learn it first.

This post is from DIY/Open Source Hardware

Comments

I collected 8 pieces and kept them for projects and more exchanges.  Details Published on 2022-7-12 11:43
 
 
 

3386

Posts

0

Resources
8
 

Experimental serial port return status

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
9
 
chrisrh posted on 2022-7-12 11:41, I also bought a Hezhou C3 at that time, but I haven’t played it yet, so I’d better learn it first

I collected 8 pieces and kept them for projects and more exchanges.

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
10
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
11
 

[Hua Diao Experience] 19 Hezhou ESP32_C3 lights up the WS2812B hard screen
experimental program 2: A basic NeoPixel light board and light bar test program

/*
  【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  实验程序二:一个基本的NeoPixel 灯板灯条测试程序
*/

#include <Adafruit_NeoPixel.h>

#define PIN 9
#define NUMPIXELS 64

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.setBrightness(50);
  strip.begin();
  strip.show(); 
}

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(255,   0,   0), 50); // Red
  colorWipe(strip.Color(  0, 255,   0), 50); // Green
  colorWipe(strip.Color(  0,   0, 255), 50); // Blue

  // Do a theater marquee effect in various colors...
  theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
  theaterChase(strip.Color(127,   0,   0), 50); // Red, half brightness
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue, half brightness

  rainbow(10);             // Flowing rainbow cycle along the whole strip
  theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
}


// Some functions of our own for creating animated effects -----------------

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
// between frames.
void theaterChase(uint32_t color, int wait) {
  for (int a = 0; a < 10; a++) { // Repeat 10 times...
    for (int b = 0; b < 3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in steps of 3...
      for (int c = b; c < strip.numPixels(); c += 3) {
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show(); // Update strip with new contents
      delay(wait);  // Pause for a moment
    }
  }
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  // Hue of first pixel runs 5 complete loops through the color wheel.
  // Color wheel has a range of 65536 but it's OK if we roll over, so
  // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
  // means we'll make 5*65536/256 = 1280 passes through this outer loop:
  for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) {
    for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (strip.numPixels() steps):
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the single-argument hue variant. The result
      // is passed through strip.gamma32() to provide 'truer' colors
      // before assigning to each pixel:
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
  }
}

// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
void theaterChaseRainbow(int wait) {
  int firstPixelHue = 0;     // First pixel starts at red (hue 0)
  for (int a = 0; a < 30; a++) { // Repeat 30 times...
    for (int b = 0; b < 3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in increments of 3...
      for (int c = b; c < strip.numPixels(); c += 3) {
        // hue of pixel 'c' is offset by an amount to make one full
        // revolution of the color wheel (range 65536) along the length
        // of the strip (strip.numPixels() steps):
        int      hue   = firstPixelHue + c * 65536L / strip.numPixels();
        uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show();                // Update strip with new contents
      delay(wait);                 // Pause for a moment
      firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
    }
  }
}

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
12
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
13
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
14
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
15
 

[Hua Diao Experience] 19 Hezhou ESP32_C3 lights up WS2812B hard screen
experimental program three: test use of the WHITE channel of 256-bit display RGBW

/*
  【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  实验程序三:256位显示 RGBW 的 WHITE 通道的测试使用
*/

#include <Adafruit_NeoPixel.h>

#define LED_PIN 9
#define LED_COUNT 256

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);

void setup() {
  strip.setBrightness(30);
  strip.begin();
  strip.show();
}

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(255,   0,   0)     , 50); // Red
  colorWipe(strip.Color(  0, 255,   0)     , 50); // Green
  colorWipe(strip.Color(  0,   0, 255)     , 50); // Blue
  colorWipe(strip.Color(  0,   0,   0, 255), 50); // True white (not RGB white)

  whiteOverRainbow(75, 5);

  pulseWhite(5);

  rainbowFade2White(3, 3, 1);
}

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

void whiteOverRainbow(int whiteSpeed, int whiteLength) {

  if (whiteLength >= strip.numPixels()) whiteLength = strip.numPixels() - 1;

  int      head          = whiteLength - 1;
  int      tail          = 0;
  int      loops         = 3;
  int      loopNum       = 0;
  uint32_t lastTime      = millis();
  uint32_t firstPixelHue = 0;

  for (;;) { // Repeat forever (or until a 'break' or 'return')
    for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
      if (((i >= tail) && (i <= head)) ||     //  If between head & tail...
          ((tail > head) && ((i >= tail) || (i <= head)))) {
        strip.setPixelColor(i, strip.Color(0, 0, 0, 255)); // Set white
      } else {                                             // else set rainbow
        int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
        strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
      }
    }

    strip.show(); // Update strip with new contents
    // There's no delay here, it just runs full-tilt until the timer and
    // counter combination below runs out.

    firstPixelHue += 40; // Advance just a little along the color wheel

    if ((millis() - lastTime) > whiteSpeed) { // Time to update head/tail?
      if (++head >= strip.numPixels()) {     // Advance head, wrap around
        head = 0;
        if (++loopNum >= loops) return;
      }
      if (++tail >= strip.numPixels()) {     // Advance tail, wrap around
        tail = 0;
      }
      lastTime = millis();                   // Save time of last movement
    }
  }
}

void pulseWhite(uint8_t wait) {
  for (int j = 0; j < 256; j++) { // Ramp up from 0 to 255
    // Fill entire strip with white at gamma-corrected brightness level 'j':
    strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
    strip.show();
    delay(wait);
  }

  for (int j = 255; j >= 0; j--) { // Ramp down from 255 to 0
    strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
    strip.show();
    delay(wait);
  }
}

void rainbowFade2White(int wait, int rainbowLoops, int whiteLoops) {
  int fadeVal = 0, fadeMax = 100;

  // Hue of first pixel runs 'rainbowLoops' complete loops through the color
  // wheel. Color wheel has a range of 65536 but it's OK if we roll over, so
  // just count from 0 to rainbowLoops*65536, using steps of 256 so we
  // advance around the wheel at a decent clip.
  for (uint32_t firstPixelHue = 0; firstPixelHue < rainbowLoops * 65536;
       firstPixelHue += 256) {

    for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...

      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (strip.numPixels() steps):
      uint32_t pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());

      // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the three-argument variant, though the
      // second value (saturation) is a constant 255.
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue, 255,
                                           255 * fadeVal / fadeMax)));
    }

    strip.show();
    delay(wait);

    if (firstPixelHue < 65536) {                             // First loop,
      if (fadeVal < fadeMax) fadeVal++;                      // fade in
    } else if (firstPixelHue >= ((rainbowLoops - 1) * 65536)) { // Last loop,
      if (fadeVal > 0) fadeVal--;                            // fade out
    } else {
      fadeVal = fadeMax; // Interim loop, make sure fade is at max
    }
  }

  for (int k = 0; k < whiteLoops; k++) {
    for (int j = 0; j < 256; j++) { // Ramp up 0 to 255
      // Fill entire strip with white at gamma-corrected brightness level 'j':
      strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
      strip.show();
    }
    delay(100); // Pause 1 second
    for (int j = 255; j >= 0; j--) { // Ramp down 255 to 0
      strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
      strip.show();
    }
  }

  delay(50); // Pause 1/2 second
}

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
16
 

Experimental scene diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
17
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
18
 

[Hua Diao Experience] 19 Hezhou ESP32_C3 lights up WS2812B hard screen
experimental program 4: 256-bit using eight fast color palettes of FastLED library

/*
  【花雕体验】19 合宙ESP32_C3点亮WS2812B硬屏
  实验程序四:256位使用FastLED库的八种快速调色板
*/

#include <FastLED.h>

#define LED_PIN     9
#define NUM_LEDS    256
#define BRIGHTNESS  20
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100

CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;


void setup() {
  delay( 3000 ); // power-up safety delay
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  FastLED.setBrightness(  BRIGHTNESS );
  currentPalette = RainbowColors_p;
  currentBlending = LINEARBLEND;
}

void loop() {
  ChangePalettePeriodically();
  static uint8_t startIndex = 0;
  startIndex = startIndex + 1; /* motion speed */
  FillLEDsFromPaletteColors( startIndex);
  FastLED.show();
  FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex) {
  uint8_t brightness = 255;
  for ( int i = 0; i < NUM_LEDS; ++i) {
    leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
    colorIndex += 3;
  }
}

void ChangePalettePeriodically() {
  uint8_t secondHand = (millis() / 1000) % 60;
  static uint8_t lastSecond = 99;
  if ( lastSecond != secondHand) {
    lastSecond = secondHand;
    if ( secondHand ==  0)  {
      currentPalette = RainbowColors_p;
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 10)  {
      currentPalette = RainbowStripeColors_p;
      currentBlending = NOBLEND;
    }
    if ( secondHand == 15)  {
      currentPalette = RainbowStripeColors_p;
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 20)  {
      SetupPurpleAndGreenPalette();
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 25)  {
      SetupTotallyRandomPalette();
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 30)  {
      SetupBlackAndWhiteStripedPalette();
      currentBlending = NOBLEND;
    }
    if ( secondHand == 35)  {
      SetupBlackAndWhiteStripedPalette();
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 40)  {
      currentPalette = CloudColors_p;
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 45)  {
      currentPalette = PartyColors_p;
      currentBlending = LINEARBLEND;
    }
    if ( secondHand == 50)  {
      currentPalette = myRedWhiteBluePalette_p;
      currentBlending = NOBLEND;
    }
    if ( secondHand == 55)  {
      currentPalette = myRedWhiteBluePalette_p;
      currentBlending = LINEARBLEND;
    }
  }
}

// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette() {
  for ( int i = 0; i < 16; ++i) {
    currentPalette[i] = CHSV( random8(), 255, random8());
  }
}

void SetupBlackAndWhiteStripedPalette() {
  // 'black out' all 16 palette entries...
  fill_solid( currentPalette, 16, CRGB::Black);
  // and set every fourth one to white.
  currentPalette[0] = CRGB::White;
  currentPalette[4] = CRGB::White;
  currentPalette[8] = CRGB::White;
  currentPalette[12] = CRGB::White;
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette() {
  CRGB purple = CHSV( HUE_PURPLE, 255, 255);
  CRGB green  = CHSV( HUE_GREEN, 255, 255);
  CRGB black  = CRGB::Black;
  currentPalette = CRGBPalette16(
                     green,  green,  black,  black,
                     purple, purple, black,  black,
                     green,  green,  black,  black,
                     purple, purple, black,  black );
}

const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
  CRGB::Red,
  CRGB::Gray, // 'white' is too bright compared to red and blue
  CRGB::Blue,
  CRGB::Black,

  CRGB::Red,
  CRGB::Gray,
  CRGB::Blue,
  CRGB::Black,

  CRGB::Red,
  CRGB::Red,
  CRGB::Gray,
  CRGB::Gray,
  CRGB::Blue,
  CRGB::Blue,
  CRGB::Black,
  CRGB::Black
};

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
19
 

Experimental scene diagram

This post is from DIY/Open Source Hardware
 
 
 

3386

Posts

0

Resources
20
 

Experimental scene diagram Dynamic diagram

This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Analog Circuit Basics Tutorial (Book)

Program Number: 799 Program name: Analog Circuit Basics Tutorial (Book) Program Type: E-book File size ...

Semiconductor Supplier Competition Focus: Next Generation IP Business

The widespread deployment of broadband networks and the popularity of VoIP applications complement each other. In additi ...

PIC series microcontroller programming basics

This book is a great help to those who want to learn PIC microcontrollers. This book is a basic tutorial book and a good ...

【Me and gui-guider①】Create a new GUI project

This post was last edited by RCSN on 2021-3-15 23:38 For the effect of porting the PC project done by gui-guider to th ...

[15th Anniversary Celebration] Let your strength speak for you, and prove that you are an EEWorlder in one sentence!

Before we know it, EEWorld is already 15 years old! Time will change, but what remains unchanged is our original intenti ...

Does the material of the transformer determine the operating frequency of the transformer?

The efficiency of the 50HZ transformer is very low at high frequency. I don't know why. Some say it is caused by eddy cu ...

LTspice .subckt(3) reverse drawing

Transformer subckt code 638335 Transformer subckt code *nominal .SUBCKT 760301108 1 2 3 4 L1 2 N001 700u Rser=0.55 ...

Award-winning live broadcast | Microchip Security Solutions Webinar 29th invites you to attend

Award-winning live broadcast | Microchip Security Solutions Webinar 29th invites you to attend To raise your awareness o ...

Why is there no data frame when analyzing MODBUS485 with logic analyzer?

I bought a logic analyzer from Zhengdian Atom, thinking of using it to analyze some communication protocols, so I tried ...

Nonlinear Control of Inverter Power Supply

Many power supplies are still controlled by traditional PID control. What nonlinear control methods are used in practica ...

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list