Home ESP8266 Wemos LED matrix shield examples

Wemos LED matrix shield examples

by iainhendry

In this article we will look at the wemos matrix shield, we will have numerous examples using the Arduino IDE

The shield is an 8×8 LED matrix, this matrix is controlled by a TM1640.  The TM1640 is a LED (Light Emitting Diode Display) drive control circuit integrating MCU digital interface, digital latch, LED high voltage drive circuit, etc

You can control the intensity of the LEDs quite easily

This is what the shield looks like

matrix led shield

matrix led shield

The following pins are used by the shield so will be unavailable for other devices

D1 mini Shield
D5 CLK
D7 DIN

 

Code Examples

You need to install the Matrix LED Shield Arduino Library

Example 1

[codesyntax lang=”cpp”]

//breathing matrix ???

#include <WEMOS_Matrix_LED.h>

MLED mled(0); //set intensity=0

void setup()
{
Serial.begin(115200);
for(int i=0; i<8; i++)
{
mled.disBuffer[i]=0xff; //full screen
}

}

void loop()
{
for(int i=0;i<8;i++)
{
mled.intensity=i;//change intensity
mled.display();
delay(100);
}
}

[/codesyntax]

 

Example 2

[codesyntax lang=”cpp”]

//draw and clear dot
#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
for(int y=0;y<8;y++)
{
for(int x=0;x<8;x++)
{
mled.dot(x,y); // draw dot
mled.display();
delay(200);
mled.dot(x,y,0);//clear dot
mled.display();
delay(200);
}
}
}

[/codesyntax]

 

Example 3

[codesyntax lang=”cpp”]

//random dot
#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5
long randX;
long randY;

void setup()
{
Serial.begin(9600);
randomSeed(analogRead(A0));
}

void loop()
{
randX = random(0, 8);
randY = random(0, 8);
mled.dot(randX,randY); // draw dot
mled.display();
delay(200);
mled.dot(randX,randY,0);//clear dot
mled.display();
delay(200);
}

[/codesyntax]

 

Example 4

[codesyntax lang=”cpp”]

#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
for(int y=0;y<8;y++)
{
mled.dot(3,y); // draw dot
mled.dot(4,y); // draw dot
mled.display();
}
}

[/codesyntax]

 

Example 5

[codesyntax lang=”cpp”]

#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
for(int x=0;x<8;x++)
{
mled.dot(x,3); // draw dot
mled.dot(x,4); // draw dot
mled.display();
}
}

[/codesyntax]

 

Example 6

[codesyntax lang=”cpp”]

//box
#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
for(int x=0;x<8;x++)
{
mled.dot(x,0); // draw dot
mled.dot(x,7); // draw dot
mled.display();
}
for(int y=0;y<8;y++)
{
mled.dot(0,y); // draw dot
mled.dot(7,y); // draw dot
mled.display();
}
}

[/codesyntax]

 

Example 7

[codesyntax lang=”cpp”]

#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
for(int x=0;x<8;x++)
{
mled.dot(x,0); // draw dot
mled.dot(x,7); // draw dot
mled.display();
}
for(int y=0;y<8;y++)
{
mled.dot(0,y); // draw dot
mled.dot(7,y); // draw dot
mled.display();
}
//lets draw a dot in the middle easy way
mled.dot(3,3); // draw dot
mled.dot(3,4); // draw dot
mled.dot(4,3); // draw dot
mled.dot(4,4); // draw dot
}

[/codesyntax]

 

Example 8

[codesyntax lang=”cpp”]

#include <WEMOS_Matrix_LED.h>

MLED mled(5); //set intensity=5

void setup()
{
}

void loop()
{
//outside lines
for(int x=0;x<8;x++)
{
mled.dot(x,0); // draw dot
mled.dot(x,7); // draw dot
mled.display();
}
for(int y=0;y<8;y++)
{
mled.dot(0,y); // draw dot
mled.dot(7,y); // draw dot
mled.display();
}
//inside lines
delay(500);
for(int x=1;x<7;x++)
{
mled.dot(x,1); // draw dot
mled.dot(x,6); // draw dot
mled.display();
}
for(int y=1;y<7;y++)
{
mled.dot(1,y); // draw dot
mled.dot(6,y); // draw dot
mled.display();
}
//inside lines 2
delay(500);
for(int x=2;x<6;x++)
{
mled.dot(x,2); // draw dot
mled.dot(x,5); // draw dot
mled.display();
}
for(int y=2;y<6;y++)
{
mled.dot(2,y); // draw dot
mled.dot(5,y); // draw dot
mled.display();
}
delay(500);
//lets draw a dot in the middle easy way
mled.dot(3,3); // draw dot
mled.dot(3,4); // draw dot
mled.dot(4,3); // draw dot
mled.dot(4,4); // draw dot
mled.display();
delay(2000);
for(int y=0;y<8;y++)
{
for(int x=0;x<8;x++)
{
mled.dot(x,y,0);//clear dot
mled.display();
}
}

}

[/codesyntax]

 

Video

This is a video of the examples above

Links

 

Matrix LED Shield V1.0.0 8 Step Adjustable Intensity for WEMOS D1 mini V1.0 8×8

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More