субота, 11. фебруар 2012.

Matrix led display controlled by Arduino and Android

Hello Arduino fans,

first i want to say big thanks to everyone who have been reading our blog recently. Every day when we see statistics about readers and see that we've been read in Emirates, France, Italy, Russia, Switzerland, USA, United Kingdom, and so on, and of course Serbia, that means a lot for us, and we get more motivation to keep writing about stuff we and you like.
In this post, we well be talking about realisation of LED matrix display controlled by Arduino and Android. The idea is to build Led matrix display from some HW components. That display is controlled by Arduino microcontroller. From Android application on your android device (tablet, mobile phone) you enter the text and send it , through Bluetooth to Led display, and text goes on like on standard (every day seen) Led displays. The idea is to build a system like on picture above.

So, that looks very nice when you see it all coneccted and all working. But, let's start from numbering and describing all components needed to bulid the final solution.

We used RG led matrix, actually this model :http://www.sparkfun.com/products/682.

 There is nothing special to say and know about led matrix, just to know what every pin is for and where to connect it. These model of led matrix has 24 pins above, and it's shown on next picture.

     Well, when we connect together some number of led matrices, there must be some component to control them, and more precisely to help pass information (text) form one 8x8 matrix to another.  Standard solutions are based on a great number of shift regsiters, transistors, capacitors and so on. In this solution other devices are used for that. The used component is MAX7219 led driver.

   The MAX7219 is a compact, serial input/output common-cathode display driver that can interface microprocessors to 7-segment numeric LED displays of up to 8 digits, bar-graph displays, or 64 individual LEDs. Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit drivers, and an 8x8 static RAM that stores each digit. Complete Datasheet can be seen at http://www.sparkfun.com/datasheets/Components/General/COM-09622-MAX7219-MAX7221.pdf. Here will be some basic words about this usefull component..

There are not yet any Leds in the schematic. There will be an extra section on Led wiring.
Besides the MAX 7219 itself and the Leds you need only 3 external components: two capacitors (C1;C2) and a resistor (RSet). The capacitors are there to supress noise signals introduced through the power-supply lines. By no means these 2 capacitors can be ommitted, as it might lead to sporadic or permanent malfunctions. These types of errors are really hard to track down. Both capacitors must be placed as near as possible to the V+ and the Gnd pins of the MAX7219. The resistor RSet is responsible for setting an upper limit on the current that is fed into the Leds. Selecting the correct resistor value might not be trivial. There is an in-depth discussion on this later.
The MAX7219 has to be powered with +5V. For a single Led-matrix it is possible to use the +5V supply from the Arduino-board. If you add more than one matrix to the Arduino you will probably need an external power-supply. 

Wiring the Arduino
Some pins of the MAX7219 led driver must be connected to Arduino - Clock Pin, Load Pin and Din pin.There is no general strict rule about that what Arduino pins are suited for named MAX7219 pins, in our case it depends of the library. In our Arduino realisation, we use Matrix.h and Sprite.h libraries, so Arduino digital pins 12 , 11 , 10 are used as Din, Load and Clock pin.
Wiring a Led matrix
The MAX72XX can drive up to an 8x8 matrix as shown in the schematic below. The labels on the left and the top of the schematic refer to the matching pins of the MAX7219.

  So, picture shows that MAX7219 pins Dig0 - Dig7 are connected to catods of the led matrix, and MAX7219 pins SegDp , SegA - SegG are connect to anodes of led matrix. So, when connecting, from earlier knowledge about pins of our used Led matrix, it shouldn't be difficult to connect everything in a right way.

Selecting a value for RSet

The Arduino forum topics concerning the MAX7219, often show that there is a fair bit of uncertainty when it comes to selecting a value for the resistor RSet. It is the single component that limits the current for all the individual Leds. While some people seem to think of this resistor as a way to control the brightness of the Leds, its real purpose is to protect the MAX7219 and the Leds from exessive currents. Setting the brightness of the display can and should be done software-controlled.

To find out the correct value for RSet you need the datasheet for the MAX7219 and the datasheet for the Led's, matrix, 7-segment display, whatever you are going to use.

From the datasheet of your Led's you will need only two values :

DC forward current

the maximum current that is allowed to go through the Led without damaging it in the long run.

Forward voltage

the voltage at which the Led operates.

While the Forward voltageis a fixed value which depends (mostly) on the color of the Led, you have to limit the current going through the Led with resistor RSet. Since DC forward current is a maximum value, which is not be exceeded, you should settle for a slightly lower current. Standard Led's and 7-segment displays are often rated with a DC forward current of 25-30mA. Limiting to 20mA would make a good choice.

With the two value from the Led's datasheet we can now lookup the resulting value for resistor RSet in the table below (which I have copied from theMAX7219 datasheet):

Mixing Leds of different colors in a matrix is not really recommended with theMAX7219. There is only one resistor RSet that limits the current for all the Leds. After you have looked all the different resistors required by your Led colors you will have to settle for the highest value. The brightness of the Leds with different colors will not really match, so it's a trial and error thing finding the right Leds.

 3. Blueetooth communication
 The text rotating on the Led matrix display is sent from Android application to Arduino chip through Bluetooth.Every important fact about Bluetooth module is in the post number 2 about Bluetooth mate silver.

  4. Arduino microcontroller
  For the microcontroller we used Arduino Uno microntroller. It is not main topic of this post to talk about Arduino micontrollers, and we hope in some next post to write about various versions of Arduino - Pro, Mega, Uno and Deumilenove and try to describe all of them and write about their characteristics. 

For the ones who cannot control curiosity about Arduino boards :), more about them can be found at http://arduino.cc/en/Main/arduinoBoardUno.

We need to explain how Arduino, MAX7219 and number of Led matrix are connected into unique system.

Clock and Load pin from Arduino are connected in-parallel with every MAX7219 drivers. Din Arduino pin goes to the most left MAX7219 led driver, and DOUT pin of that driver to DIN pin of the next driver and so on. We already explained how the pins from MAX7219 led drivers are connected to Led matrix. 
So, i think it's enough about HW. In the next post we will explain the Arduino code of the fina solution, and also Android application and give some important source code that can be usefull to our readers. For the end, some more pictures of our system.

11 коментара:

  1. Hi..Can you send me arduıno code? ( ı have t make a project with max and arduıno (5 max)

  2. Your blog article is really very informative. Thanks for your sharing and please keep sharing.
    led video screen

  3. Thanks for always being the source that explains things instead of just putting an unjustified answer out there. I loved this post.
    Led curtain

  4. You welcome... if you have any questions, just ask and if we can, will answer with explanations and examples as much as we can.

  5. Аутор је уклонио коментар.

  6. pleasee i need code please help me salwakhlif@gmail.com

  7. i need code to display led according to my desire