Colorful Message With Grove Beginner Kit and RGB Led Matrix
by tuenhidiy in Circuits > Arduino
1903 Views, 7 Favorites, 0 Comments
Colorful Message With Grove Beginner Kit and RGB Led Matrix
Today, I'd like to share how to create a colorful message displayed on the RGB led matrix by Grove Beginner Kit For Arduino from Seeedstudio. In this project, the led matrix background and letter colors can be customized base on the Grove Beginner Kit built-in sensors.
Let's getting started.
Supplies
Main components are as follows:
- 1 x Grove Beginner Kit for Arduino.
- 320 x 5mm Common Anode RGB LEDs.
- 16 x A1013 Transistors.
- 2 x Shift Register 74HC595N.
- 9 x Power Logic 8-Bit Shift Register TPIC6B595N.
- 12 x 0.1uF Decoupling Capacitors.
- 100 x 100Ω Resistors.
- 16 x 1kΩ Resistors.
- 1 x Single-Side Copper Prototype PCB Size A4.
- 1 x Proto Shield for Arduino.
- 2 x Clear Acrylic Plate Size A4.
- 2 x Male & Female 40pin 2.54mm Header.
- 1 x Power Supply 5V.
- 1 x DC Power Supply Male & Female Socket.
- 1 x DC Power Supply Screw Type.
- 8 x Copper Standoff Spacers 20mm.
- 2 meter x Rainbow Color Flat Ribbon Cable.
Grove Beginner Kit for Arduino
The Grove Beginner Kit for Arduino® is powered by one Arduino UNO compatible Board (ATmega320p based Seeeduino Lotus) together with 10 additional Grove Arduino sensors all in one piece of the board.
All modules are pre-wired, no breadboard and jumper cables required.
You can go to SeeedStudio wiki page, there are full of tutorials and codes for getting started.
Idea
I have built one RGB led table 16x20 which was controlled by SPI protocol, and reserved 4 control pins for future applications as follow:
- DATA PIN
- CLOCK PIN
- LATCH PIN
- BLANK PIN
You can check how I built this led matrix at: https://www.instructables.com/ATtiny85-Spectrum-A...
My idea is to combine this led board and Grove Beginner Kit to display information and make color customizations based on Grove Beginner Kit built-in sensors.
Schematic
You can download the project schematic in PDF format HERE.
The components for controlling a RGB led matrix 16x20 via SPI:
- Columns (cathodes) scanning: including 3 groups of TPIC6B595N to control 20 columns, each group includes 3 x TPIC6B595N for 3 colors: Red, Green & Blue.
- Rows (anodes) scanning: including 2 x 74HC595N and 16 x A1013 transistor to control 16 rows.
The connection between Led Matrix 16x20 and ATmega320p based Seeeduino Lotus on the Grove Beginner Kit is as follow:
- DATA_PIN: connect to Seeeduino Lotus pin D11 (MOSI).
- CLOCK_PIN: connect to Seeeduino Lotus pin D13 (SCK).
- LATCH_PIN: connect to Seeeduino Lotus pin D2.
- BLANK_PIN: connect to Seeeduino Lotus pin D7.
Soldering and Assembling Works
- Soldering a RGB Led Matrix 16x20: I reused this led matrix from previous project. You can check detail at:
https://www.instructables.com/ATtiny85-Spectrum-An...
- Soldering 4 SPI pins male header on a Proto Shield for Arduino.
- Proto Shield for Arduino was plugged on the Seeeduino Lotus and Grove Beginner Kit was mounted on the backside of led matrix. Then I connected 5VDC power supply and SPI connection to Grove Beginner Kit.
- Ready for programming.
Programming
The project code is available at my GitHub:
How It Works
In this project, I used Rotary Potentiometer and 3-Axis Acceleration Sensor to determine the colors of scrolling message, for both letter & background. Details are as follows:
1. Led matrix background color is decided by 3-Axis Acceleration Sensors on the Grove Begginer Kit. For each different pose of led table, it will show a different color. To avoid the signal noises, these acceleration values are saved only if their changes are bigger than the preseted limit value (eg, LIMIT_BAND_ACC = 0.10).
void GetAcceleration() { ax = accelemeter.getAccelerationX(); ay = accelemeter.getAccelerationY(); az = accelemeter.getAccelerationZ(); // Save the values if their changes are bigger than the preseted limit value, eg: 0.1. if (abs(ax - prev_ax) > LIMIT_BAND_ACC) { increment_colour_pos(colourPos + (uint16_t)abs(ax*16)); prev_ax = ax; } if (abs(ay - prev_ay) > LIMIT_BAND_ACC) { increment_colour_pos(colourPos + (uint16_t)abs(ay*16)); prev_ay = ay; } if (abs(az - prev_az) > LIMIT_BAND_ACC) { increment_colour_pos(colourPos + (uint16_t)abs(az*16)); prev_az = az; } }
2. Letter and number color is based on Rotary Potentiometer on the Grove Begginer Kit. Its color is displayed in "colorwheel", corresponding to the position of potentiometer knob. As same as the acceleration sensor, its values is saved only if its changes is bigger than the preseted limit value (eg, LIMIT_BAND_POT = 10).
void readPotentio() { POT = map(analogRead(POTPIN), 0, 1023, 0, 255); // Save the potentiometer value if its change is bigger than a presetedlimit value, eg: 10. if (abs(POT - OLD_POT) > LIMIT_BAND_POT) { OLD_POT = POT; } }
3. The surrounding atmospheric pressure BMP280 will be read, converted & notified on the led matrix.
void GetPressure() { rawpressure = bmp280.getPressure(); // Convert to kPa pressure = rawpressure/1000; Pressure[11] = ((pressure/ 100) % 10) + 48; Pressure[12] = ((pressure/10) %10) + 48; Pressure[13] = (pressure%10) + 48; }
4. The message will be scrolled on the led matrix with:
- Bk_color (background color): following to values of 3-Axis Acceleration Sensors.
- For_color (letter & number color): following to value of Rotary Potentiometer.
// FONT 8x16 else if (font == FONT8x16) { while (times) { GetAcceleration(); get_colour(colourPos , &Bk_color.red, &Bk_color.green, &Bk_color.blue); for ((dir) ? offset=0 : offset=((lenString(mystring)-6)*9-1); (dir) ? offset <((lenString(mystring)-6)*9-1) : offset >0; (dir) ? offset++ : offset--) { for (byte xx=0; xx<20; xx++) { for (byte yy=0; yy<16; yy++) { readPotentio(); get_colour(OLD_POT + 4*yy + 4*xx, &For_color.red, &For_color.green, &For_color.blue); if (getPixelHString(xx+offset, yy, mystring, FONT8x16)) { setcolor = For_color; } else { setcolor = Bk_color; } LED(xx,(yy+y), setcolor.red, setcolor.green, setcolor.blue); } } delay(delaytime); } times--; } }
5. 4-Bit B.A.M (Bit Angle Modulation) is applied to control RGB led matrix.
6. The letters and numbers can be shown in 4 fonts sizes:
- Font 3x5
- Font 5x7
- Font 8x8
- Font 8x16
Testings & Conclusion
Grove Beginner Kit worked great with RGB led matrix through SPI protocol. Many built-in sensors can be used depending on our creativeness, just with one Grove Beginner Kit.
Thank you for reading my work!!!