Overview
From point to line, from line to face. Now began to come to a piece of LED, a big splash LED is coming!
Sample Program
Since there are no ready-made modules at hand, there are only 595 at hand, so each of these sample programs uses the 74HC595 extension IO port. No more notes in the back.
Ready-made modules and other special driver chip, the program is more simple to write, according to the specific driver chip to determine the program, this program is not universal OH.
Dot matrix shows a still heart
Don't look at the static two words, here the lattice is dynamic scanning yo. Therefore, there is no delay function in the program to block the main function such as delay ().
// ----------------------------------------------------------------------------//Ledlattice.ino// //Created 2015-06-07//by Seesea <seesea2517#gmail#com>// //LED dot Matrix//single-color LED lattice with two 74hc959 drives// // ----------------------------------------------------------------------------ConstUnsignedCharLatchpin =Ten;//595 of ST_CPConstUnsignedCharClockpin =9;//595 of SH_CPConstUnsignedCharDatapin =8;//595 of DS#defineSIZE 7//number of columns in lattice//modulo values for each rowConst byteRow[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//heart-shaped moldConst byteHeart[] ={ 0xFF,0x93,0x6d,0x7d,0xBB,0xD7,0xEF,0xFF};voidSetup () {Pinmode (Latchpin, OUTPUT); Pinmode (Clockpin, OUTPUT); Pinmode (Datapin, OUTPUT); Serial.begin (9600);}voidLoop () {showarrpic (heart);}//display the picture represented by the arrayvoidShowarrpic (Const bytearr[]) { for(unsignedChari =0; I <8; ++i) {digitalwrite (Latchpin, low); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) arr[i]); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) row[i]); Digitalwrite (Latchpin, high); }}//another way to display the picture represented by the arrayvoidShowArrPic2 (Const bytearr[]) { StaticUnsignedChari =0; Digitalwrite (Latchpin, low); Shiftout (Datapin, Clockpin, Lsbfirst, Arr[i]); Shiftout (Datapin, Clockpin, Lsbfirst, Row[i]); Digitalwrite (Latchpin, high); if(++i >=SIZE) I=0;}
Simply look at the wiring bar, no ready-made modules, are hand-made, pure natural ... Not recommended to take, trouble time is also prone to error. (Lazy only at VCC to connect a current-limiting resistor, the effect is also passable, not afraid of trouble students can add a few:D )
The Falling Heart
Yes, it's moving, so it's a dynamic scan. Well, the preceding statement is a demonstration of the error:D
This program demonstrates a displacement animation.
// ----------------------------------------------------------------------------//Latticedownheart.ino// //Created 2015-06-07//by Seesea <seesea2517#gmail#com>// //dot-matrix animation: Falling Heart//use two 74hc959 to drive monochrome LED dot matrix, show a downward falling heart, show displacement animation// // ----------------------------------------------------------------------------ConstUnsignedCharLatchpin =Ten;//595 of ST_CPConstUnsignedCharClockpin =9;//595 of SH_CPConstUnsignedCharDatapin =8;//595 of DSConstUnsignedLongDelayms = -;//Image Motion delay time#defineSIZE 8//number of columns in lattice//modulo values for each rowConst byteRow[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//heart-shaped moldConst byteHeart[] ={ 0xFF,0x93,0x6d,0x7d,0xBB,0xD7,0xEF,0xFF};voidSetup () {Pinmode (Latchpin, OUTPUT); Pinmode (Clockpin, OUTPUT); Pinmode (Datapin, OUTPUT); Serial.begin (9600);}voidLoop () {Static Chary =-8; StaticUnsignedLongLasttick =Millis (); //after a certain time delay, move the coordinates if(Millis ()-Lasttick >delayms) { ++y; Lasttick=Millis (); if(Y >SIZE) y= -8; } showarrpic (Heart,0, y);}//display the picture represented by the array//with (x, y) as the start position of the upper left corner, the default is shown in (0, 0) position//coordinate system://+------>// | X// |//v y// voidShowarrpic (Const byteArr[],CharXChary) { for(Chari =0; i < SIZE; ++i) {if(i + x <0|| i + x >= SIZE | |I+ Y <0|| i + y >=SIZE) { Continue; } digitalwrite (Latchpin, low); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) Arr[i +x]); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) Row[i +y]); Digitalwrite (Latchpin, high); }}
Walking around the villain
A frame-by-step animation is shown here.
// ----------------------------------------------------------------------------//Ledlattice.ino////Created 2015-06-07//by Seesea <seesea2517#gmail#com>////dot-matrix animation: A step-by-step animated demonstration of character walking//single-color LED lattice with two 74hc959 drives//// ----------------------------------------------------------------------------ConstUnsignedCharLatchpin =Ten;//595 of ST_CPConstUnsignedCharClockpin =9;//595 of SH_CPConstUnsignedCharDatapin =8;//595 of DSConstUnsignedLongFramedelayms = $;#defineFrame_num 4//number of keyframe frames#defineSIZE 8//number of columns in lattice//modulo values for each rowConst byteRow[] ={ 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//the modeling of the key frame of the character walkingConst byteMan[frame_num][size] ={ {0xE7,0xE7,0xFF,0xC3,0xC5,0xE7,0xDB,0xBD}, {0xE7,0xE7,0xFF,0xE7,0xe3,0xE7,0xEB,0xDB}, {0xE7,0xE7,0xFF,0xE7,0xE7,0xE7,0xE7,0xE7}, {0xE7,0xE7,0xFF,0xE7,0xe3,0xE7,0xEB,0xDB}};voidSetup () {Pinmode (Latchpin, OUTPUT); Pinmode (Clockpin, OUTPUT); Pinmode (Datapin, OUTPUT); Serial.begin (9600);}voidLoop () {StaticUnsignedLongLasttick =Millis (); StaticUnsignedCharframe =0; //after a frame time delay, go to the next frame if(Millis ()-Lasttick >=framedelayms) {Lasttick=Millis (); ++frame; if(Frame >=frame_num) FRAME=0; } showarrpic (Man[frame]);}//display the picture represented by the arrayvoidShowarrpic (Const bytearr[]) { for(unsignedChari =0; i < SIZE; ++i) {digitalwrite (Latchpin, low); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) arr[i]); Shiftout (Datapin, Clockpin, Lsbfirst, (byte) row[i]); Digitalwrite (Latchpin, high); }}
No painting, this is all manual point out of the lattice the more you look like, we will point it:
An example of an Arduino starter program LED (2015-06-11)