回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

川剧变脸(麦昆小车变形记) 简单

头像 huangq1228 2019.05.14 1325 1

麦昆小车来到了身边

project-image

有幸参加粒子老师的麦昆脑洞大开的活动,特地向瀚瀚_luna老师询问了情况,购买了micro:bit板和扩展板。 企盼着,企盼着,终于盼来了快递。一辆小巧的麦昆小车轻松装好。

project-image
project-image
project-image
project-image
project-image
project-image
project-image

清单:

micro bit板
麦昆小车

A4纸

戏剧任务素材

川剧变脸,是中华著名文化艺术,也是中国非物质文化遗产,更是国家文化二级机密。我想用bit的点阵屏,来做川剧的变脸,我在网上找到了一张京剧的图片,根据bit板点阵屏大小进行编辑,然后把它打印出来。

project-image
project-image

用小刀把戏剧人物雕刻下来。

project-image
project-image

然后把它粘贴在麦昆小车上。一个有趣的戏剧人物就出现了

project-image
project-image
project-image

借用了其他小车的一个遥控器,利用mind+程序把遥控器的按键数字读了出来,然后整理成了一张按键的数字表,最后我们通过编辑变脸程序逐个逐个添加图谱进去。

project-image
project-image
project-image
project-image
project-image

餐具变脸完成后,给瀚瀚_luna老师看了,老师说好像这个是有点矮,像个武大郎,然后就想办法能能不能做一个bit的连长线?网上找了很久,没有,就想自己来加工,找了一块坏网卡,锯下了等长的插口,试了几次,都没有成功。

project-image
project-image
project-image
project-image
project-image

材料清单

  • micro bit板 X1
  • 麦昆小车 X1
  • A4锡剧人物 X1
  • 遥控器 X1
代码
#include <DFRobot_IRremote_dal.h>
#include <Microbit_Matrix.h>
#include <Maqueen_Motor.h>
#include <DFRobot_NeoPixel.h>

double df_bianlian;
double df_dongzuo;
double df_bl2;
double df_d2;
double df_hong;
double df_lan;
double df_lu;

DFROBOT_IRremote_Receive remote(16);
const uint8_t bitmap_KJKd[5] = {B00000,B11011,B00000,B01010,B00100};
const uint8_t bitmap_QQxk[5] = {B01010,B10001,B00000,B00100,B01010};
const uint8_t bitmap_cT_7[5] = {B10001,B11011,B00000,B01110,B00000};
const uint8_t bitmap_0NNN[5] = {B11011,B10001,B00000,B00000,B01110};
const uint8_t bitmap_dFUb[5] = {B01010,B11111,B11111,B01110,B00100};
const uint8_t bitmap_LVcj[5] = {B11111,B00100,B11111,B00100,B11111};
const uint8_t bitmap_0FRR[5] = {B10001,B10101,B10101,B10101,B10001};
const uint8_t bitmap_Q0JJ[5] = {B00000,B11011,B00100,B00100,B01110};
const uint8_t bitmap_M6wb[5] = {B10001,B10001,B01010,B00000,B00100};
Maqueen_Motor motor;
const uint8_t bitmap_2JJI[5] = {B00000,B11011,B00000,B01010,B00100};
const uint8_t bitmap_gYYa[5] = {B01010,B10001,B00000,B00100,B01010};
const uint8_t bitmap_gwaF[5] = {B10001,B11011,B00000,B01110,B00000};
const uint8_t bitmap_Rr7r[5] = {B11011,B10001,B00000,B00000,B01110};
const uint8_t bitmap_dN3x[5] = {B01010,B11111,B11111,B01110,B00100};
const uint8_t bitmap_KNEE[5] = {B11111,B00100,B11111,B00100,B11111};
const uint8_t bitmap_guBK[5] = {B10001,B10101,B10101,B10101,B10001};
const uint8_t bitmap_fjCd[5] = {B00000,B11011,B00100,B00100,B01110};
const uint8_t bitmap_5q5q[5] = {B10001,B10001,B01010,B00000,B00100};
DFRobot_NeoPixel  rgb_display_15;

void onIRReceive(uint8_t data_IR)
{
	if ((data_IR == 207)) {
		MMatrix.show(bitmap_KJKd);
	}
	if ((data_IR == 231)) {
		MMatrix.show(bitmap_QQxk);
	}
	if ((data_IR == 133)) {
		MMatrix.show(bitmap_cT_7);
	}
	if ((data_IR == 239)) {
		MMatrix.show(bitmap_0NNN);
	}
	if ((data_IR == 199)) {
		MMatrix.show(bitmap_dFUb);
	}
	if ((data_IR == 165)) {
		MMatrix.show(bitmap_LVcj);
	}
	if ((data_IR == 189)) {
		MMatrix.show(bitmap_0FRR);
	}
	if ((data_IR == 181)) {
		MMatrix.show(bitmap_Q0JJ);
	}
	if ((data_IR == 173)) {
		MMatrix.show(bitmap_M6wb);
	}
	if ((data_IR == 151)) {
		MMatrix.clear();
	}
	if ((data_IR == 31)) {
		motor.motorRun(motor.LEFT,motor.CW,100);
	}
	if ((data_IR == 253)) {
		motor.motorRun(motor.LEFT,motor.CW,100);
		motor.motorRun(motor.RIGHT,motor.CW,100);
	}
	if ((data_IR == 111)) {
		motor.motorRun(motor.RIGHT,motor.CW,100);
	}
	if ((data_IR == 103)) {
		motor.motorRun(motor.LEFT,motor.CCW,100);
		motor.motorRun(motor.RIGHT,motor.CCW,100);
	}
	if ((data_IR == 87)) {
		motor.motorStop(motor.LEFT);
		motor.motorStop(motor.RIGHT);
	}
	if ((data_IR == 93)) {
		for (int count = 0; count < 1000; count++) {
			df_bianlian = (random(1, 9+1));
			df_dongzuo = (random(1, 4+1));
			if ((df_bianlian == df_bl2)) {
				df_bianlian = (random(1, 9+1));
			}
			else {
				if ((df_dongzuo == df_d2)) {
					df_dongzuo = (random(1, 4+1));
				}
				else {
					if ((df_bianlian == 1)) {
						MMatrix.show(bitmap_2JJI);
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 2)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_gYYa);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 3)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_gwaF);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 4)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_Rr7r);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 5)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_dN3x);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 6)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_KNEE);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 7)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_guBK);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 8)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_fjCd);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					if ((df_bianlian == 9)) {
						df_bl2 = df_bianlian;
						df_d2 = df_dongzuo;
						MMatrix.show(bitmap_5q5q);
						if ((df_dongzuo == 1)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
						}
						if ((df_dongzuo == 3)) {
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 2)) {
							motor.motorRun(motor.LEFT,motor.CW,100);
							motor.motorRun(motor.RIGHT,motor.CW,100);
						}
						if ((df_dongzuo == 4)) {
							motor.motorRun(motor.LEFT,motor.CCW,100);
							motor.motorRun(motor.RIGHT,motor.CCW,100);
						}
					}
					delay(300);
				}
			}
		}
	}
}


void setup() {
	remote.begin();
	remote.setCallback(onIRReceive);
	dfrobotRandomSeed();
	rgb_display_15.begin(15, 4, 255);
}

void loop() {
	df_hong = (random(1, 255+1));
	df_lan = (random(1, 255+1));
	df_lu = (random(1, 255+1));
	rgb_display_15.setRangeColor(0, 0, rgb_display_15.rgbToColor(round(df_hong), round(df_lu), round(df_lan)));
	df_hong = (random(1, 255+1));
	df_lan = (random(1, 255+1));
	df_lu = (random(1, 255+1));
	rgb_display_15.setRangeColor(1, 1, rgb_display_15.rgbToColor(round(df_hong), round(df_lu), round(df_lan)));
	df_hong = (random(1, 255+1));
	df_lan = (random(1, 255+1));
	df_lu = (random(1, 255+1));
	rgb_display_15.setRangeColor(2, 2, rgb_display_15.rgbToColor(round(df_hong), round(df_lu), round(df_lan)));
	df_hong = (random(1, 255+1));
	df_lan = (random(1, 255+1));
	df_lu = (random(1, 255+1));
	rgb_display_15.setRangeColor(3, 3, rgb_display_15.rgbToColor(round(df_hong), round(df_lu), round(df_lan)));
	delay(500);
}

评论

user-avatar
  • 木子呢

    木子呢2019.05.16

    好有创意,赞一个!

    0