Interfacing DOT MATRIX ARRAY with Arduino
Who doesn’t like Dot matrix displays!!! A blast from the past, that still brings the charm. Dot matrix LEDs are very popular means of displaying information as it allows both static and animated text as well as images. You might have noticed them at some public domains, such as advertisements, display pricing, along side the highways, petrol pumps etc. Here we will begin with a single monochrome 5×7 dot matrix display.
About LED dot matrix
Led matrix is an array of multiple LEDs arranged in a row by column order. Arrangement of the LEDs in the matrix pattern is made in either of the two ways – row anode – column cathode or row cathode – column anode. The matrix pattern minimizes the number of pins required to drive them. In this sample project 35 LEDs are controlled using a combination of 12 pins. Desired character or graphics can be displayed by switching ON /OFF a desired configuration of LED’s, the perfection is (depends) on the number of LEDs on dot matrix. To light up an LED make corresponding cathode low and anode high. The quick scanning of row and column makes the data visible to our eyes, i.e. persistence of vision.
Hardware connection
A minimum of 12 pins are required to wire up the dot matrix with an Arduino board, rows use 7 pins while columns need 5 pins. The rows are driven by pin1 through pin7 and the columns are driven by pin8 through pin12 of Arduino.
Rows
R0 → 1
R1 → 2
R2 → 3
R3 → 4
R4 → 5
R5 → 6
R6 → 7
Columns
C0 → 8
C1 → 9
C2 → 10
C3 → 11
C4 → 12
Example Code
Note: The logic levels to load the row and column to turn on LEDs depends on your display. The sample code is written for matrix with row cathode – column anode i.e, row=0 and column=1 turns the led on.
Some displays come with rows anode and columns cathode, i.e, row=1 and column=0 turns the led on. Make sure your program compatible with your display.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
byte r0 = 1; // pin 9 of dot matrix byte r1 = 2; // pin 14 byte r2 = 3; // pin 8 byte r3 = 4; // pin 12 byte r4 = 5; // pin 1 byte r5 = 6; // pin 7 byte r6 = 7; // pin 2 -bottom row byte c0 = 8; // pin 13 byte c1 = 9; // pin 3 byte c2 = 10; // pin 11 byte c3 = 11; // pin 10 byte c4 = 12; // pin 6 - right hand column byte columnArray[] = {c0,c1,c2,c3,c4}; // Place all pins in an array byte rowArray[] = {r0,r1,r2,r3,r4,r5,r6}; /* Complement the array if you use rows anode and columns cathode type display*/ byte pixels_array[36][5]= { // 2-dimensional array of pixels 0x02, 0xEC, 0xEC, 0xEC, 0x02, //A 0x00, 0x6C, 0x6C, 0x6C, 0x92, //B 0x82, 0x7C, 0x7C, 0x7C, 0xBA, //C 0x00, 0x7C, 0x7C, 0x7C, 0x82, //D 0x00, 0x6C, 0x6C, 0x6C, 0x6C, //E 0x00, 0xEC, 0xEC, 0xEC, 0xEC, //F 0x82, 0x7C, 0x6C, 0x6C, 0x8A, //G 0x00, 0xEE, 0xEE, 0xEE, 0x00, //H 0x7C, 0x7C, 0x00, 0x7C, 0x7C, //I 0xBD, 0x7D, 0x7D, 0x80, 0xFC, //J 0x00, 0xEE, 0xD6, 0xBA, 0x7C, //K 0x00, 0x7E, 0x7E, 0x7E, 0x7E, //L 0x00, 0xFA, 0xF6, 0xFA, 0x00, //M 0x00, 0xF6, 0xEE, 0xDE, 0x00, //N 0xC6, 0xBA, 0xBA, 0xBA, 0xC6, //0 0x00, 0xEC, 0xEC, 0xEC, 0xF2, //P 0xC2, 0xBC, 0x9C, 0xBC, 0x42, //Q 0x00, 0xEC, 0xCC, 0xAC, 0x72, //R 0xB2, 0x6C, 0x6C, 0x6C, 0x9A, //S 0xFC, 0xFC, 0x00, 0xFC, 0xFC, //T 0x80, 0x7E, 0x7E, 0x7E, 0x80, //U 0xC0, 0xBE, 0x7E, 0xBE, 0xC0, //V 0x00, 0xBE, 0xDE, 0xBE, 0x00, //W 0x38, 0xD6, 0xEE, 0xD6, 0x38, //X 0xF8, 0xF6, 0x0E, 0xF6, 0xF8, //Y 0x3C, 0x5C, 0x6C, 0x74, 0x78, //Z 0x82, 0x7C, 0x7C, 0x7C, 0x82, //0 0x77, 0x7A, 0x00, 0x7E, 0x7E, //1 0x3A, 0x5C, 0x6C, 0x74, 0x7A, //2 0x6C, 0x6C, 0x6C, 0x6C, 0x92, //3 0XCF, 0XD6, 0XDB, 0X00, 0XDE, //4 0xA0, 0x6C, 0x6C, 0x6C, 0x9C, //5 0x82, 0x6C, 0x6C, 0x6C, 0x9B, //6 0xFC, 0xFC, 0x0C, 0xF4, 0xF8, //7 0x92, 0x6C, 0x6C, 0x6C, 0x92, //8 0xB2, 0x6C, 0x6C, 0x6C, 0x82, //9 }; int pxl_clmn, cnt=0,i,pxl_row; void setup() { for (i=0; i<5; i++) { pinMode(columnArray[i], OUTPUT); // Set column pins as output } for (i=0; i<=7; i++) { // Set row pins as output pinMode(rowArray[i], OUTPUT); } } void loop() { for (pxl_row = 0; pxl_row<36; pxl_row++) // Input the characters { while(i<=100) // Scanning across the column { i++; for (pxl_clmn=0; pxl_clmn<5; pxl_clmn++) // Row selection { /* If you use rows anode and columns cathode type display, complement this pin */ digitalWrite (columnArray[ pxl_clmn], HIGH); // Make anode HIGH to turn LED on PORTD = 0xff & pixels_array[pxl_row][pxl_clmn]; // Row value directly load to PORTTD(pin 1 to 7) delay(3); // Delay between column switching digitalWrite (columnArray[pxl_clmn], LOW); // Turn off column } } i=0; } } |
Leave a Reply
You must be logged in to post a comment.