Colorful Message With Grove Beginner Kit and RGB Led Matrix

by tuenhidiy in Circuits > Arduino

1839 Views, 7 Favorites, 0 Comments

Colorful Message With Grove Beginner Kit and RGB Led Matrix

Title_1.jpg
Matrix good.jpg

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:

Grove Beginner Kit for Arduino

Grove_Sensors.jpg

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

Matrix 1.jpg

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

GROVE_BEGINNER_KIT_RGB_16x20_schem.jpg

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:

https://github.com/tuenhidiy/GROVE-BEGINNER-KIT-MA...

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

Good 3.jpg
Good 1.jpg
Good 2.jpg

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!!!