Introduction: Controlling LED Matrix Array With Arduino Uno (Arduino Powered Robot Face)

This instructable shows how to control an array of 8x8 LED matrices using an Arduino Uno. This guide might be used to create a simple (and relatively cheap display) for your own projects. This way you might display letters, numbers or custom animations.


A 5 matrices array used in one of our robot projects ("Robô da Alegria") is used as an example to ilustrate this technology. You might found more about this project in the following links:
https://hackaday.io/project/12873-rob-da-alegria-joy-robot

https://github.com/ferauche/RoboAlegria

https://www.facebook.com/robodaalegria/

Special thanks to the other team members involved in the above mentioned project, responsible for the first version of the code presented in this tutorial:
Thiago Farauche
Diego Augustus
Yhan Christian

Step 1: Components

The following components were used in this project:

  • Arduino Uno
  • 8x8 LED matrix array with MAX7219 driver (x5)
  • Female-to-female jumper wires (4 jumpers of 5 cables each)
  • Male-to-famale jumper wires (1 jumper of 5 cables)
  • 2mm acrylic sheet (optional for fixation of the components)
  • M2 x 10 mm bolts (x20) (optional for fixation of the components)
  • M2 x 1,5 mm nuts (x20) (optional for fixation of the components)
  • A computer (for compiling and uploading Arduino code)
  • Creativity

Notice that you'll need two types of jumpers: female-to-female for the connection between the matrices and a male-to-female for the connection of the firts matrix to the Arduino.

The number of components may vary according to the structure you have in mind.

Step 2: Assembly

Connect all the componets according to the schematic. You'll need some jumper wires to connect the first matrix to the Arduino, and each matrix to the next one on the array.

Arduino Pinout:

  • Arduino digital pin 13 = DIN of the first display
  • Arduino digital pin 12 = CLK of the fist display
  • Arduino digital pin 11 = CS of the first display
  • Arduino 5V pin = Vcc of the first display
  • Arduino GND pin = Gnd pin of the first display

You might also want to arrange each display in a given position. For that you might use a acrilic sheet, some bolts and nuts (four for each display) and place each component in position.

No tool is needed to assemble the circuit, but you will need a screwdriver or sharp tool if you wish attach the displays to a surface with some bolts and nuts. In our example, five displays were placed in a face pattern (two eyes and a mouth).

Plug the USB cable to the Arduino Uno board and proceed to the next step.

Step 3: Coding

With the latest Arduino IDE version installed, add the LedControl.h library, which is used to control the LEDs.

Download, compile and upload Arduino the code, which is divided in 4 parts:
1. Definition of the eyes and mouth: each eye is configured and a 8-byte array. The mouths are defined as a 24-byte array;
2. Setup: configure displays and start communication;
3. Main: wait for serial communication commands and choose which face will be displayed;
4. Auxiliary functions: functions for setting eyes' and mouth's displays.

setRow function was used to set each row of the LED display. It was used instead of setColumn because it runs eight times faster! This way, the drawings for each display have to be declared rotated 90 degrees counter-clockwise.

setIntensity was used to limit LEDs brightness. It was set as 1 (in a scale from 0 to 15) in order to reduce the power consumption of the modules to a level aceptable by the USB port.

Step 4: Usage

After the upload keep the Arduino connected to the USB port of your computer and open the Serial Monitor.
The code is programmed to display a set of emoticons on the LED face, depending on the message received by the serial port.
The following commands were configured:

For the eyes

  • : (normal eyes)
  • ; (blink)
  • 8 (spooky eyes)

For the mouth:

  • ) (happy)
  • | (neutral)
  • ( (sad)
  • D or d (very happy)
  • O or o (surprised)
  • P or p (tongue out)

Type a pair of characters (one for the eyes and other for the mouth) in the serial monitor, press enter and the displays will be updated according to your command.

You might change the drawings (add new faces for instance) or change the control method (including a bluetooth or wi-fi interface), according to your needs.

Have fun!

Comments

author
RobotFarmer (author)2016-10-12

IgorF2

I got the parts on order. Can't wait to put build it. Going to use it in a pumpkin for my Cub Scouts. Thanks for your hard work. I'm just getting started myself.

author
IgorF2 (author)RobotFarmer2016-10-12

Thanks, RobotFarmer! That's a good idea: develop some evil faces, put it in a pumpkin and use it as a Halloween decor!

author
RobotFarmer (author)IgorF22016-10-19

Bugging you one more time. Plan "A" 8x8's not working so well. I guess I went too cheap on parts. However Plan "B" I also bought (at the same time) a " SainSmart MAX7219 Dot Matrix Module 4 in one for Arduino ". At the end of your sketch you wrote "Characters must be declared rotated 90 degrees..." As I am new to this and want to have this ready for Scouts on Tuesday, How do I declare the rotation? Your help is VERY much appecerated.

author
IgorF2 made it! (author)RobotFarmer2016-10-20

Actually, there isn't a function to perform this rotation, What I ment is that the matrix designed in the code is rotated 90 degrees when it's displayed in the LED module, as show in the image bellow.

So you have to keep that in mind when you design the eyes and mouths in the code. In other words, every line in the code represents a column in the LED matrix.

Please let me know if there is any doubt.

Capturar.PNG
author
RobotFarmer (author)IgorF22016-10-20

Ok I get it. I'll give it a whorl. Thanks again.

author
RobotFarmer (author)RobotFarmer2016-10-20

Thanks again for you help. I got it going. So cool and Learning a little more on programming.

author
Dillonwest (author)2016-10-18

hi, I made one of these and am now wondering if there is any more information on programming it. Any links or even books I could purchase that would help would be great! Thanks!!

author
Dillonwest (author)Dillonwest2016-10-18

I mainly need help with how I would go about changing the code to use different faces, and have it on a change mode button to switch them.

author
IgorF2 (author)Dillonwest2016-10-19

Let me see if I understood correctly: you want to design some new faces and switch them by pressing a physical push buttons? If that's the case, I can try to help you.
Regarding your other comment, there is a lot of books and tutorials available online. Most of the times you can find the solution to your problems on online forums as well. You can also learn a lot from the examples available on Arduino IDE.

author
Dillonwest (author)IgorF22016-10-19

yes, on my standalone atmega328 board I have a button connected to pin #4 as a 'switch mode' button. I have all my boards assembled and connected, just need to get the atmega328 programmed. I don't have much experience with arduino, I'll be sure to look at the examples on arduino ide. Thanks!!!

author
IgorF2 (author)Dillonwest2016-10-20

I see. I think that basically you'll have to check if the button is pressed. If it is, incremment an integer, which is compared to select the face.

I can help you with the code, if you need it.

author
chopperaddict (author)2016-08-07

Nice one, but a circuit diagram would have helped those of us that have never set one of these things up ? The 3D view is OK but doesn't really show exactly what pins on the arduino go to the LED display ?

author
IgorF2 (author)chopperaddict2016-08-07

Thanks, chopperaddict. I didn't notice that the resolution of the schematic wasn't good (it is impossible to see the number of the pins). So I added two more images on Step 2: a zoom showing the connection of the Arduino to the first display, and a detail showing the connection between first and second displays. I also added a pinout description. I hope it helps.

Fritzing circuit diagram for the LED display isn't very intuitive. You can check it out in the Fritzing file on Step 2.

Please let me know if there is something else you think I should improve. :D

author
SteveQuinn (author)2016-08-04

Hi Igor,

Thanks for the fritzing part. I was able to export ot so I'll extract it properly later.

Regards

Steve

author
IgorF2 (author)SteveQuinn2016-08-04

You're welcome, Steve!

author
SteveQuinn (author)2016-08-03

Hi IgorF2,

Well done on the instructable, presumably you made your own 8by8 LED Matrix fritzing part. I gave up trying to create one, had a rant and used a stock part. :-)

Regards

SteveQuinn

author
IgorF2 (author)SteveQuinn2016-08-04

Hi Steve! I added the Fritzing file on Step 2. Maybe you can copy the component from there.
I hope it helps.

author
mrsharkit (author)2016-08-02

Are you sure an arduino can power all these leds? Mine cannot go beyond 3 8x8 modules, if all leds are on...

author
IgorF2 (author)mrsharkit2016-08-02

I tested on my Arduino Uno and it worked fine with five 8x8 LED modules, powered directly from the USB port.

Notice that I restricted the brightness to 1 (in a scale from 0 to 15) using the setIntensity function. This reduced the power consumed by each display.

Did you try to reduce the brightness of your modules?

author
mrsharkit (author)IgorF22016-08-02

You already answered... Better using external power for complete use of the modules... Thanks

author
IgorF2 (author)mrsharkit2016-08-02

You're welcome. Since my application is intended for indoor use, brightness is not critical. But if you need brighter LEDs I'll really gona need an external power source.

About This Instructable

8,310views

132favorites

License:

More by IgorF2:3D Printed Tool HangerWiDC - Wi-Fi Controlled FPV Robot (with Arduino, ESP8266 and DC Motors)Solar Charged Battery Powered Arduino Uno
Add instructable to: