Tutorial on how to interface MAX7219 7 segment display module with arduino?
A module suggestion for those who need to use 7 segment display without having to connect a lot of wires, this display module 7 8 digit segments, with IC MAX7219 .
As you can see by the image, we can print some characters in this display and, of course, to show the numbers.Another way to trigger the display, which we shall see, is to use a sequence of bits to trigger the corresponding segments on the display and create our own symbols.
That means that we are activating only the segments E and G of the display.
A module suggestion for those who need to use 7 segment display without having to connect a lot of wires, this display module 7 8 digit segments, with IC MAX7219 .
As you can see by the image, we can print some characters in this display and, of course, to show the numbers.Another way to trigger the display, which we shall see, is to use a sequence of bits to trigger the corresponding segments on the display and create our own symbols.
The operation of the 8-digit module is very similar to what we saw in these posts because it also uses only three pins (left) to connect the Arduino or other microcontroller .
The right side, we find the pins that allow the connection of several modules in cascade:
The circuit for connection to Arduino this way is then, with the pins 5, 6 and 7 respectively connected to pinsLOAD , CLK and DIN :
Program Library :
The library LedControl , which can be downloaded at this link is who will control the display of the drive. The main commands LedControl used in the program:
LedControl LedControl lc = (7, 6, 5, 1) = Sets the pins to be connected to the module. Pin 7 of the Arduino to DIN 6 pin to CLK and pin 5 to LOAD. The latter figure refers to the number of modules that are connected to the Arduino.
lc.shutdown (0, false) = This command also serves to initialize the display also serves to clear the display without losing any data in memory. This command is especially useful when the module is being powered by batteries, since we can show the data on the display only when triggered a button, for example. In this case, just change the last parameter to TRUE when you do not want the display to remain on.
lc.setIntensity (modulo, value) = regulates the brightness of the display. The first parameter is the module number, and value can be a number between 0 (minimum) to 15 (maximum brightness).
lc.setChar (modulo, digit, character, false) = Prints a character on the display. Despite not having many characters available due to limited display of 7 segments, we can use the characters A, B, C, D, E, F, H, L and P.
lc.setDigit (modulo, type, value, ponto_decimal) = used to directly send a number or the value of a variable for a given type in the display. The parameter ponto_decimal can receive the values TRUE (displays the decimal point), or FALSE (disables the decimal point).
Arduino Code for MAX7219 Display Interface:
Arduino Code for MAX7219 Display Interface:
// Program: Display 7 segments - 8 digit MAX7219 // Load the LedControl library
#include "LedControl.h" // Definitions pins and number of modules in the circuit LedControl lc = LedControl ( 7 , 6 , 5 , 1 ); void setup () { // Initialize the module lc.shutdown ( 0 , false); // display brightness adjustment lc.setIntensity ( 0 , 3 ); // Delete the display lc.clearDisplay ( 0 ); } void loop () { // Send Arduino for display writeArduinoOn7Segment (); // Countdown countdown(); // Init counter 0 1 million for ( long i = 0 ; i < 1000000 ; i ++) { printNumber (i); } delay ( 500 ); } void printNumber ( long v) { // Variable value digit int digito1; int digito2; int digito3; int digito4; int digito5; int digito6; int digito7; int digito8; // Calculate the value of each digit digito1 v =% 10 ; digito2 = (V / 10 )% 10 ; digito3 = (V / 100 )% 10 ; digito4 = (V / 1000 )% 10 ; digito5 = (V / 10000 )% 10 ; digito6 = (v / 100000 )% 10 ; digito7 = (v / 1000000 )% 10 ; digito8 = (v / 10000000 )% 10 ; // Display the value of each digit in the display lc.setDigit ( 0 , 7 , (byte) digito8, false); lc.setDigit ( 0 , 6 , (byte) digito7, false); lc.setDigit ( 0 , 5 , (byte) digito6, false); lc.setDigit ( 0 , 4 , (byte) digito5, false); lc.setDigit ( 0 , 3 , (byte) digito4, false); lc.setDigit ( 0 , 2 , (byte) digito3, false); lc.setDigit ( 0 , 1 , (byte) digito2, false); lc.setDigit ( 0 , 0 , (byte) digito1, false); delay ( 00 ); } void writeArduinoOn7Segment () { // Arduino on the display for ( int i = 0 ; i < 21 ; i ++) { lc.setChar ( 0 , i, 'a' , false); lc.setRow ( 0 , i 1 , 0x05 ); lc.setChar ( 0 , i- 2 , 'd' , false); lc.setRow ( 0 , i- 3 , 0x1c ); lc.setRow ( 0 , i- 4 , B00010000); lc.setRow ( 0 , i 5 , 0x15 ); lc.setRow ( 0 , i- 6 , 0x1D ); lc.setChar ( 0 , i- 7 , '' , false); lc.setChar ( 0 , i- 8 , 'and' , false); lc.setChar ( 0 , i- 9 , '' , false); lc.setRow ( 0 , i- 10 , B1001110); lc.setRow ( 0 , i- 11 , B0010000); lc.setChar ( 0 , i- 12 , 'a' , false); lc.setChar ( 0 , i- 13 , '' , false); delay ( 300 ); } }
Finally, to activate only certain segments of the display, use the command lc.setRow () , which has the following syntax:
See for example the letter "R", we write on the display using this command: lc.setRow (0, I type, 0x05) In binary, the command looks like this: lc.setRow (0, digit, B00000101 )
lc.setRow (numero_modulo, I type, value) = We can define value in decimal, hex or binary, but the command is easier to understand if we use binary.
See for example the letter "R", we write on the display using this command: lc.setRow (0, I type, 0x05) In binary, the command looks like this: lc.setRow (0, digit, B00000101 )
That means that we are activating only the segments E and G of the display.
No comments:
Post a Comment