【炫Q香蕉派】香蕉派BPI RGB LED Matrix点阵模块应用资料


#1

首先从香蕉派BPI RGB LED Matrix点阵模块开始吧,第一楼汇集现有资料的链接,欢迎大家补充
gitbook资料
https://bananapi.gitbooks.io/bpi-accessories/content/en/RGbLEDMatrixmodule.html

英文论坛资料
http://forum.banana-pi.org/t/bpi-m3-bpi-8x8-led-matrix-module-and-how-to-use/1096



#2

官方没有找到这个点阵的datasheet,找了一些屏幕相关的参数,晚上再结合实物实测一下





正面看左到右,下到上
公共正1-8,R1-8,G1-8,B1-8


#3

首先1脚连接一个电阻,我用的10K,毕竟直接CPU出来的,电流能小就小MikuDuino入门可以参看
https://help.mikuduino.com/document/c10_struct.html
连接1脚3.3V到公共正1(比忘了10K电阻),连接7脚到蓝色1(B1),就可以直接测试blink的例子了

/*
 * blink.cpp:
 *
 *	Welcome to MikuQ.com! MikuDuino for BananaPi 
 *	
 *     by MikuQ(i@mikuq.com) 2016-6-2
 *	
 * https://github.com/bpiq/MikuPi
 *
 */

#include "MikuDuino.h"

#define	LED D7

void setup()
{
	pinMode (LED, OUTPUT) ;
}

void loop()
{
	digitalWrite (LED, HIGH) ;
	delay(500);
	digitalWrite (LED, LOW) ;
	delay(500);
}

make
sudo ./blink
左上角的蓝灯闪烁


#4

再来个进阶的,什么呢?流水灯!这次正极不变,然后把引脚8、10、12、16、18、22、24、26八个引脚接到红色1-8(R1-8)上,
为啥是这些引脚呢?原因看这里https://help.mikuduino.com/document/c20_led.html,因为并不是每个引脚都可控

/*
 * water.cpp:
 *
 *	Welcome to MikuQ.com! MikuDuino for BananaPi 
 *	
 *     by MikuQ(i@mikuq.com) 2016-12-13
 *	
 * https://github.com/bpiq/MikuPi
 *
 */

#include "MikuDuino.h"

#define	LED1 D8
#define	LED2 D10
#define	LED3 D12

#define	LED4 D16
#define	LED5 D18

#define	LED6 D22
#define	LED7 D24
#define	LED8 D26

#define SPACE 100

void setup()
{
	pinMode (LED1, OUTPUT);
	pinMode (LED2, OUTPUT);
	pinMode (LED3, OUTPUT);
	pinMode (LED4, OUTPUT);
	pinMode (LED5, OUTPUT);
	pinMode (LED6, OUTPUT);
	pinMode (LED7, OUTPUT);
	pinMode (LED8, OUTPUT);
	digitalWrite (LED1, HIGH);
	digitalWrite (LED2, HIGH);
	digitalWrite (LED3, HIGH);
	digitalWrite (LED4, HIGH);
	digitalWrite (LED5, HIGH);
	digitalWrite (LED6, HIGH);
	digitalWrite (LED7, HIGH);
	digitalWrite (LED8, HIGH);
}

void loop()
{
	digitalWrite (LED1, LOW);
	delay(SPACE);
	digitalWrite (LED1, HIGH);
	digitalWrite (LED2, LOW);
	delay(SPACE);
	digitalWrite (LED2, HIGH);
	digitalWrite (LED3, LOW);
	delay(SPACE);
	digitalWrite (LED3, HIGH);
	digitalWrite (LED4, LOW);
	delay(SPACE);
	digitalWrite (LED4, HIGH);
	digitalWrite (LED5, LOW);
	delay(SPACE);
	digitalWrite (LED5, HIGH);
	digitalWrite (LED6, LOW);
	delay(SPACE);
	digitalWrite (LED6, HIGH);
	digitalWrite (LED7, LOW);
	delay(SPACE);
	digitalWrite (LED7, HIGH);
	digitalWrite (LED8, LOW);
	delay(SPACE);
	digitalWrite (LED8, HIGH);
}

make
sudo ./water
红灯从左到右,流动起来


#5

最新程序,这次不说怎么接线,程序写得很清楚,明白人一看就知道了

/*
 * water2.cpp:
 *
 *	Welcome to MikuQ.com! MikuDuino for BananaPi 
 *	
 *     by MikuQ(i@mikuq.com) 2016-12-14
 *	
 * https://github.com/bpiq/MikuPi
 *
 */

#include "MikuDuino.h"

#define	LED1 D8
#define	LED2 D10
#define	LED3 D12

#define	LED4 D16
#define	LED5 D18

#define	LED6 D22
#define	LED7 D24
#define	LED8 D26

#define V1   D3
#define V2   D5
#define V3   D7

#define V4   D11
#define V5   D13
#define V6   D15

#define V7   D19
#define V8   D21

#define SPACE 100

void setup()
{
	pinMode (LED1, OUTPUT);
	pinMode (LED2, OUTPUT);
	pinMode (LED3, OUTPUT);
	pinMode (LED4, OUTPUT);
	pinMode (LED5, OUTPUT);
	pinMode (LED6, OUTPUT);
	pinMode (LED7, OUTPUT);
	pinMode (LED8, OUTPUT);
	digitalWrite (LED1, HIGH);
	digitalWrite (LED2, HIGH);
	digitalWrite (LED3, HIGH);
	digitalWrite (LED4, HIGH);
	digitalWrite (LED5, HIGH);
	digitalWrite (LED6, HIGH);
	digitalWrite (LED7, HIGH);
	digitalWrite (LED8, HIGH);
	pinMode (V1, OUTPUT);
	pinMode (V2, OUTPUT);
	pinMode (V3, OUTPUT);
	pinMode (V4, OUTPUT);
	pinMode (V5, OUTPUT);
	pinMode (V6, OUTPUT);
	pinMode (V7, OUTPUT);
	pinMode (V8, OUTPUT);
	digitalWrite (V1, LOW);
	digitalWrite (V2, LOW);
	digitalWrite (V3, LOW);
	digitalWrite (V4, LOW);
	digitalWrite (V5, LOW);
	digitalWrite (V6, LOW);
	digitalWrite (V7, LOW);
	digitalWrite (V8, LOW);
}

void loop()
{
	digitalWrite (V1, HIGH);
	digitalWrite (LED1, LOW);
	delay(SPACE);
	digitalWrite (LED1, HIGH);
	digitalWrite (LED2, LOW);
	delay(SPACE);
	digitalWrite (LED2, HIGH);
	digitalWrite (LED3, LOW);
	delay(SPACE);
	digitalWrite (LED3, HIGH);
	digitalWrite (LED4, LOW);
	delay(SPACE);
	digitalWrite (LED4, HIGH);
	digitalWrite (LED5, LOW);
	delay(SPACE);
	digitalWrite (LED5, HIGH);
	digitalWrite (LED6, LOW);
	delay(SPACE);
	digitalWrite (LED6, HIGH);
	digitalWrite (LED7, LOW);
	delay(SPACE);
	digitalWrite (LED7, HIGH);
	digitalWrite (LED8, LOW);
	delay(SPACE);
	digitalWrite (V1, LOW);
	digitalWrite (V2, HIGH);
	delay(SPACE);
	digitalWrite (V2, LOW);
	digitalWrite (V3, HIGH);
	delay(SPACE);
	digitalWrite (V3, LOW);
	digitalWrite (V4, HIGH);
	delay(SPACE);
	digitalWrite (V4, LOW);
	digitalWrite (V5, HIGH);
	delay(SPACE);
	digitalWrite (V5, LOW);
	digitalWrite (V6, HIGH);
	delay(SPACE);
	digitalWrite (V6, LOW);
	digitalWrite (V7, HIGH);
	delay(SPACE);
	digitalWrite (V7, LOW);
	digitalWrite (V8, HIGH);
	delay(SPACE);
	digitalWrite (LED8, HIGH);
	digitalWrite (LED7, LOW);
	delay(SPACE);
	digitalWrite (LED7, HIGH);
	digitalWrite (LED6, LOW);
	delay(SPACE);
	digitalWrite (LED6, HIGH);
	digitalWrite (LED5, LOW);
	delay(SPACE);
	digitalWrite (LED5, HIGH);
	digitalWrite (LED4, LOW);
	delay(SPACE);
	digitalWrite (LED4, HIGH);
	digitalWrite (LED3, LOW);
	delay(SPACE);
	digitalWrite (LED3, HIGH);
	digitalWrite (LED2, LOW);
	delay(SPACE);
	digitalWrite (LED2, HIGH);
	digitalWrite (LED1, LOW);
	delay(SPACE);
	digitalWrite (V8, LOW);
	digitalWrite (V7, HIGH);
	delay(SPACE);
	digitalWrite (V7, LOW);
	digitalWrite (V6, HIGH);
	delay(SPACE);
	digitalWrite (V6, LOW);
	digitalWrite (V5, HIGH);
	delay(SPACE);
	digitalWrite (V5, LOW);
	digitalWrite (V4, HIGH);
	delay(SPACE);
	digitalWrite (V4, LOW);
	digitalWrite (V3, HIGH);
	delay(SPACE);
	digitalWrite (V3, LOW);
	digitalWrite (V2, HIGH);
	delay(SPACE);
	digitalWrite (V2, LOW);
}

make
sudo ./water2



#6

学会了用数组,代码简练了很多

/*
 * se.cpp:
 *
 *	Welcome to MikuQ.com! MikuDuino for BananaPi 
 *	
 *     by MikuQ(i@mikuq.com) 2016-12-18
 *	
 * https://github.com/bpiq/MikuPi
 *
 */

#include "MikuDuino.h"

const int led[8] = {D8, D10, D12, D16, D18, D22, D24, D26};
const int v[8] = {D3, D5, D7, D11, D13, D15, D19, D21};

void setup()
{
	int i;
	for(i=0;i<8;i++)
	{
		pinMode (led*, OUTPUT);
		digitalWrite (led*, HIGH);
		pinMode (v*, OUTPUT);
		digitalWrite (v*, LOW);
	}
}

void loop()
{
	int i,j;
	for(j=0;j<8;j++)
	{
		digitalWrite (v[j], HIGH);
		for(i=0;i<8;i++)
		{
			if (((j<2)||(j>5))&&((i<2)||(i>5))||((i>2)&&(i<5)&&(j>2)&&(j<5)))
			{
				digitalWrite (led*, LOW);
				delay(0);
				digitalWrite (led*, HIGH);
			}
		}
		digitalWrite (v[j], LOW);
	}
}


******


#7
/*
 * se2.cpp:
 *
 *	Welcome to MikuQ.com! MikuDuino for BananaPi 
 *	
 *     by MikuQ(i@mikuq.com) 2016-12-18
 *	
 * https://github.com/bpiq/MikuPi
 *
 */

#include "MikuDuino.h"

const int led[8] = {D8, D10, D12, D16, D18, D22, D24, D26};
const int v[8] = {D3, D5, D7, D11, D13, D15, D19, D21};

void setup()
{
	int i;
	for(i=0;i<8;i++)
	{
		pinMode (led*, OUTPUT);
		digitalWrite (led*, HIGH);
		pinMode (v*, OUTPUT);
		digitalWrite (v*, LOW);
	}
}

void loop()
{
	int i,j,k;
	int x=10;
	for(k=0;k<4;k++)
	{
		digitalWrite (v[k], HIGH);
		for(i=k;i<8-k;i++)
		{
			digitalWrite (led*, LOW);
			delay(x);
			digitalWrite (led*, HIGH);
		}
		digitalWrite (v[k], LOW);
		digitalWrite (led[7-k], LOW);
		for(i=k+1;i<8-k;i++)
		{
			digitalWrite (v*, HIGH);
			delay(x);
			digitalWrite (v*, LOW);
		}
		digitalWrite (led[7-k], HIGH);			
		digitalWrite (v[7-k], HIGH);
		for(i=6-k;i>k;i--)
		{
			digitalWrite (led*, LOW);
			delay(x);
			digitalWrite (led*, HIGH);
		}
		digitalWrite (v[7-k], LOW);
		digitalWrite (led[k], LOW);
		for(i=7-k;i>k;i--)
		{
			digitalWrite (v*, HIGH);
			delay(x);
			digitalWrite (v*, LOW);
		}
		digitalWrite (led[k], HIGH);			
	}
	for(k=3;k>0;k--)
	{
		digitalWrite (v[k], HIGH);
		for(i=k;i<8-k;i++)
		{
			digitalWrite (led*, LOW);
			delay(x);
			digitalWrite (led*, HIGH);
		}
		digitalWrite (v[k], LOW);
		digitalWrite (led[8-k], LOW);
		for(i=k;i<8-k;i++)
		{
			digitalWrite (v*, HIGH);
			delay(x);
			digitalWrite (v*, LOW);
		}
		digitalWrite (led[8-k], HIGH);			
		digitalWrite (v[8-k], HIGH);
		for(i=8-k;i>=k;i--)
		{
			digitalWrite (led*, LOW);
			delay(x);
			digitalWrite (led*, HIGH);
		}
		digitalWrite (v[8-k], LOW);
		digitalWrite (led[k-1], LOW);
		for(i=8-k;i>=k;i--)
		{
			digitalWrite (v*, HIGH);
			delay(x);
			digitalWrite (v*, LOW);
		}
		digitalWrite (led[k-1], HIGH);			
	}

}


********************


#8

占楼


#9

占楼


#10

占楼


#11

占楼


#12

楼都被占完了。。。支持