Skip to content

Commit 1c836f3

Browse files
committed
CJMCU-8*8 RGB LED matrix example added
1 parent 490dcb1 commit 1c836f3

File tree

12 files changed

+116
-6
lines changed

12 files changed

+116
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*~
2+
libraries
3+
libraries/*

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# arduino
2-
Arduino libraries and sketches
2+
3+
Arduino libraries and sketches.
4+
5+
6+
<!-- vim-markdown-toc GFM -->
7+
8+
* [Libraries](#libraries)
9+
* [JLed](#jled)
10+
* [log4arduino](#log4arduino)
11+
* [Sketches](#sketches)
12+
* [Interfacing SSD1306 based OLED displays (SPI)](#interfacing-ssd1306-based-oled-displays-spi)
13+
* [Colorduino RGB matrix driver](#colorduino-rgb-matrix-driver)
14+
* [CMJMCU-8x8 RGB matix](#cmjmcu-8x8-rgb-matix)
15+
16+
<!-- vim-markdown-toc -->
317

418
## Libraries
519

620
### JLed
7-
JLed is an Arduino library to control LEDs. It uses a non-blocking approach and can control LEDs in simple (on/off) and complex (blinking, breathing) ways in a time-driven manner.
21+
22+
JLed is an Arduino library to control LEDs. It uses a non-blocking approach and
23+
can control LEDs in simple (on/off) and complex (blinking, breathing) ways in a
24+
time-driven manner.
825

926
* https://github.com/jandelgado/jled
1027

@@ -16,12 +33,27 @@ A lightweight, no-frills logging library for Arduino & friends.
1633

1734
## Sketches
1835

19-
### interfacing SSD1306 based OLED displays (SPI)
36+
### Interfacing SSD1306 based OLED displays (SPI)
37+
38+
<img alt="ssd1306" width=256 src="images/ssd1306.jpg">
2039

21-
* ssd1306_sample_adafruit - sample code for ssd1306 based oled display. see [wiki](http://github.com/pacodelgado/arduino/wiki/SSD1306-based-OLED-connected-to-Arduino) for detailed information
22-
* ssd1306_sample_u8g - sample code for ssd1306 based oled display. see [wiki](http://github.com/pacodelgado/arduino/wiki/SSD1306-based-OLED-connected-to-Arduino) for detailed information
40+
* [ssd1306_sample_adafruit](ssd1306_sample_adafruit) - sample code for ssd1306 based oled display. see [wiki](http://github.com/jandelgado/arduino/wiki/SSD1306-based-OLED-connected-to-Arduino) for detailed information
41+
* [ssd1306_sample_u8g](ssd1306_sample_u8g) - sample code for ssd1306 based oled display. see [wiki](http://github.com/jandelgado/arduino/wiki/SSD1306-based-OLED-connected-to-Arduino) for detailed information
2342

2443

2544
### Colorduino RGB matrix driver
2645

27-
* see [wiki](https://github.com/pacodelgado/arduino/wiki/Colorduino) for detailed information
46+
Driver for 8x8 RGB LED matrix.
47+
48+
<img alt="Colorduino" width=256 src="images/colorduino.JPG">
49+
50+
* see [wiki](https://github.com/jandelgado/arduino/wiki/Colorduino) for detailed information
51+
52+
53+
### CMJMCU-8x8 RGB matix
54+
55+
An 8x8 LED RGB matrix based on WS2812 "NeoPixels".
56+
57+
<img alt="CJMCU-8*8" width=256 src="images/cjmcu-8x8/cjmcu.jpg">
58+
59+
* see [README of example sketch](cjmcu_8x8_sample/README.md) for detailed information.

cjmcu_8x8_sample/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# CJMCU-8*8 LED RGB Matrix
2+
3+
<img alt="CJMCU-8*8" width=480 src="../images/cjmcu-8x8/cjmcu.jpg">
4+
5+
I recently got some of those `CMCJU-8*8` labeled LED RGB Matrix boards.
6+
According to what is printed on the boards, they are opposed to be built
7+
up on `WS2812B` RGB "Neopixel" LEDs. Connecting the matrix to an Arduino however,
8+
I had no luck at all on my first attempt. Later I found that these PCBs were
9+
totally misleadingly labeled:
10+
11+
* `DIN` and `DOUT` labels are exchanged (!)
12+
* the board uses `WS2812` LEDs, which use the WS2811 driver IC (but is labeled as
13+
`WS2812B`)
14+
15+
| Front | Back |
16+
| ----- | ---- |
17+
| ![CJMCU-8*8 front](../images/cjmcu-8x8/cjmcu_front.jpg) | ![CJMCU-8*8 back](../images/cjmcu-8x8/cjmcu_back.jpg) |
18+
19+
Knowing that, I could get the board up and running using the FastLED library
20+
without problem. [See the Demo sketch for an example](cjmcu_8x8_sample.ino).
21+
The sketch assumes the CJMCU board is connected to pin D9 of an Arduino.
22+
23+
Since the WS2812 (which is an WS2811 driver IC packaged with a LED) and the WS2812B
24+
use the same protocol, the difference in type make no difference in interfacing
25+
the LEDs with e.g. the [FastLED library](https://github.com/FastLED/FastLED).
26+
27+
## Spot the difference
28+
29+
The WS2812 uses a 6 pin package. So if your LEDs have 6 pins instead of 4,
30+
then chances are your PCB is populated with WS2812 LEDs.
31+
32+
![ws2812 detail](../images/cjmcu-8x8/ws2812_detail.jpg)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Demo for CJMCU-8*8 LED RGB Matrix. Demo assumes CJMCU connected
2+
// to an Arduino nano on PIN D9
3+
// Jan Delgado 2018
4+
#include <FastLED.h>
5+
6+
// LED configutration
7+
#define LED_TYPE WS2812B // type of LED in use. CJMCU works with
8+
// WS2811,WS2812,WS2812B (compatible)
9+
10+
constexpr auto LED_DT = 9; // Pin WS2812 Data in (DIN) is connected to
11+
constexpr auto COLOR_ORDER = GRB;
12+
constexpr auto NUM_LEDS = 64;
13+
constexpr auto SPEED_MS = 50;
14+
15+
CRGB leds[NUM_LEDS];
16+
17+
void setup() {
18+
19+
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
20+
FastLED.setBrightness(128);
21+
22+
// FastLED 2.1 Power management set at 5V, 500mA
23+
set_max_power_in_volts_and_milliamps(5, 500);
24+
CRGB cols[] = {CRGB::Red, CRGB::Green, CRGB::Blue};
25+
26+
for(auto c : cols) {
27+
for(auto i = 0; i<NUM_LEDS; i++ ) {
28+
leds[i] = c;
29+
}
30+
FastLED.show();
31+
delay(1000);
32+
}
33+
}
34+
35+
void loop() {
36+
static int hue = 0;
37+
static int delta_hue = 4;
38+
39+
EVERY_N_MILLISECONDS(SPEED_MS) {
40+
fill_rainbow(leds, NUM_LEDS, hue++, delta_hue);
41+
}
42+
show_at_max_brightness_for_power();
43+
}

images/cjmcu-8x8/cjmcu.jpg

358 KB
Loading

images/cjmcu-8x8/cjmcu_back.jpg

260 KB
Loading

images/cjmcu-8x8/cjmcu_front.jpg

469 KB
Loading

images/cjmcu-8x8/ws2812_detail.jpg

70.6 KB
Loading

images/colorduino.JPG

100755100644
File mode changed.

images/led_matrix_mono.jpg

100755100644
File mode changed.

0 commit comments

Comments
 (0)