Latest Arduino Driver 12 interface/outdoor LED display/led dot matrix panel/led Unit Board

Source: Internet
Author: User

Cause

The existing drive LED display data, better than the only this. But it drives the 08-interface indoor display, and I'm going to drive a 12-port outdoor display. The difference between the two screens is that the outdoor screen lattice is sparse, and both of the scanning mode, the driving style is not the same. It took me an afternoon to find out the way it was used, so I shared it with you and I hope you don't have to detour.

Material preparation
    • 12 interface (outdoor) LED unit board piece: for example, I bought from [here], we search "semi-outdoor LED unit Board" on it. My board is 16x32 size.
    • Arduino Uno Piece
    • 5V Power One (such as charging the treasure, the head to charge the phone)
Hardware construction 1. Display Power supply welding

The LED unit uses a 5V power supply, but it only provides two screw-on local power supply. So we want to do the following welding: USB male +,-to the Wire +,-。 After this, the USB plugs directly into the phone charger/charging PO and the wire is connected to the power supply on the display.

2.Arduino connection to the display

First we need to know the definition of each pin of the 12 interface:

OE   an    BN    CN    clkn    HSN    RN    ggnd  D
    • N: Indicates no use
    • A,b,c,d: Line Selection. Since we are 16x32, we will only use a A, B (that is, 0~3), as for why wait for the back
    • OE: Enable. If it is high, the screen will light up and the low will force all lights to extinguish.
    • GND: Ground. (No VCC pins in these pins ...) I don't know why it works properly.
    • Clk,hs,r: It is the shcp,stcp,ds in 74hc595. Specific self-learning 595 chip.
    • G: Originally meant green, we are not useless because it is monochromatic.

The next step is to connect them to the Arduino pin. The default settings for my library are as follows:

Const int A=2,constint b=3,constint clk=,const int stb=,constint r= one,constint oe=9

Of course, you can also modify the library when it is initialized.

Software build 1. Library code

I wrote a library myself with the following code:

#include <Arduino.h>#include"DotMatrix.h"classLedscreenhelper { Public: Ledscreenhelper (Const intWidth= +,            Const intA=2,Const intb=3,Const intclk= A,            Const intstb=Ten,Const intR= One,Const intOe=9): HEIGHT ( -), Width (width), a (a), B (b), Shcp (CLK), Stcp (STB), DS (R), OE (OE) {}voidSetup () {Pinmode (a,output);        Pinmode (B,output);        Pinmode (Stcp,output);        Pinmode (Shcp,output);        Pinmode (Ds,output);    Pinmode (Oe,output); }        voidSetrow (byterow) {Digitalwrite (A,row&0x01); Digitalwrite (B,row&0x02); }        voidSendcoldata (bytedata) {         for(inti =0;i<8;++i) {Digitalwrite (DS, (Data&0x80)); Data<<=1; Digitalwrite (SHCP,0); Digitalwrite (SHCP,1); }    }        voidSetoe (BOOLenable)    {Digitalwrite (OE, enable); }        voidDisplay (DotMatrix &data) {         for(introw =0;row<4;++row) {Digitalwrite (OE,0);  for(intCol =0; col<width/2;++Col) {                byteval = data.Get(( A-((col&3) <<2) (+row), (col>>2)); Sendcoldata (~val);            } setrow (row); Digitalwrite (STCP,0); Digitalwrite (STCP,1); Digitalwrite (OE,1); } digitalwrite (OE,0); }    Private:    Const intHeight,width; Const intA,b,shcp,stcp,ds,oe;};

It needs to include "DotMatrix.h" as follows:

#ifndef Dot_matrix#defineDot_matrixtypedef unsignedCharUchar;#defineTHROW (str);#defineByte_len 8#defineCheck_var (I,j) if ((i) <0| | (j) <0| | (i) >=height| | (j) >=width) THROW ("Index Out of Bound")#definePOS (MATRIX,I,J) (* (Matrix) + (i) * (width) + (j)))#definePos_bit_get (Matrix,i,j) (POS (Matrix), (i), (j)/byte_len) & (1<< (byte_len-(j)%byte_len-1)))#definePos_bit_set_true (Matrix,i,j) (POS (Matrix), (i), (j)/byte_len) |= (1<< (byte_len-(j)%byte_len-1)))#definePos_bit_set_false (Matrix,i,j) (POS (Matrix), (i), (j)/byte_len) &= (0xFF ^ (1<< (byte_len-(j)%byte_len-1)))#definePos_bit_set (M,i,j,b) ((b)!=0)? Pos_bit_set_true ((m), (i), (j)):P Os_bit_set_false ((m), (i), (j))/** * Remember:this class would only use ' matrix ' and not DELETE it*/classDotMatrix { Public: DotMatrix (intWintH,uchar *matrix,BOOLisnowclearmatrix=true): Width (w), Height (h), matrix (matrix) {if(Isnowclearmatrix) cleardata (); } DotMatrix (ConstDotMatrix &src) {Serial.println ("DotMatrix copy construction-please avoid"); Width=Src.width; Height=Src.height; Matrix=Src.matrix; }    ~DotMatrix () {}voidClearData () {memset (Matrix,0, width*height*1); } Inlinevoid Set(intIintJ,uchar val)        {Check_var (I,J); POS (MATRIX,I,J)=Val; } Inline UcharGet(intIintj)        {Check_var (I,J); returnPOS (MATRIX,I,J); } InlinevoidSetbit (intIintJbit,BOOLb) {Check_var (I,jbit/8);    Pos_bit_set (MATRIX,I,JBIT,B); } InlineBOOLGetbit (intIintjbit) {Check_var (I,jbit/8); returnPos_bit_get (matrix,i,jbit); }    voidFillto (DotMatrix &fillto,intXoffset,intYoffset,intScale ) {         This->fillto (Fillto,xoffset,yoffset,scale,scale,0,0, width*byte_len,height); }    /** * Fill the rect [xsrcbeg,ysrcbeg,xsrcend,ysrcend] to ' fillto ' by the ' offset ' and ' scale ' * @param the Thing S by **bit***/    voidFillto (DotMatrix &fillto,intXoffset,intYoffset,intXScale,intYscale,intXsrcbeg,intYsrcbeg,intXsrcend,intysrcend) {         for(inti = ysrcbeg;i<ysrcend;++i) {             for(intj = xsrcbeg;j<xsrcend;++j) {                 for(intIi=0; ii<yscale;++II) {                     for(intjj=0; jj<xscale;++JJ) {                        //Var_dump_inline (i); Var_dump_inline (j); Var_dump_inline (ii); Var_dump (JJ);Fillto.setbit (yoffset+ (I-ysrcbeg) *yscale+ii, xoffset+ (J-xsrcbeg) *xscale+JJ, Pos_bit_get (MATRIX,I,J)); }                }            }        }    }    voidprint () { for(inti =0; ii) {             for(intj =0; j<width;++j) {                 for(intK =7; k>=0;--k) {Serial.print (Get(I,J) & (1&LT;&LT;K))! =0); } serial.print (" "); } serial.println (" ");    } serial.flush (); }    intgetwidth () {returnwidth; }    intgetheight () {returnheight; } Uchar*Getmatrix () {returnMatrix; }Private:    intWidth,height; Uchar*Matrix;Private: FriendclassDisplayhelper;};#undefByte_len#undefPos#undefPos_bit#endif

Explain, DotMatrix This class is a two-dimensional matrix operation class, as long as it is a one-dimensional array as a storage space, it can simulate a two-dimensional array. This can reduce memory allocation and destruction on the Arduino.

2. Use of libraries
#include <Arduino.h>#include"LEDScreenHelper.h"Ledscreenhelper helper;unsignedChardata[4* -];D Otmatrix Matrix (4, -, data);voidSetup () {helper.setup ();  for(inti =0;i< -;++i) {         for(intj =0;j<4;++j) {matrix.Set(i,j,i+j* -); }    }}voidLoop () {helper.display (matrix);}

Routine as above. The effect is to think of the screen as a coordinate system (0,0) in the upper-left corner, then 8 points (1byte) as a piece, each block of 0-3bit represents the y-coordinate, and 4-5bit represents the J-coordinate.

The effect is as follows:

Precautions
    1. If you drive that piece of board, you do not need to buy 40 of that kind of switching power! Even if you want to buy, also first ask how and 220V to connect, seemingly want to engage in the connection line.
    2. Do not let it remain on the program, but to make most of the time oe=0, that is, not bright. This is equivalent to PWM, which can reduce its power consumption, and thus the power supply of 5V 2 A is sufficient.
    3. It seems that the power supply of the display can not be connected, then it will be more bright; it seems that the display power and Arduino power is not common, although some people say to share, some people even say to the same power. I don't know what I'm going to do, I have someone to know, please tell me.

Latest Arduino Driver 12 interface/outdoor LED display/led dot matrix panel/led Unit Board

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.