所有分类
主题 主题
平台 平台
我的工作台
userHead
注册时间 [[userInfo.create_time]]
创造力 [[userInfo.creativity]]
[[userInfo.remark]]
[[d.project_title]]
articleThumb
[[d.material_name]]
timelineThumb
进入工作台
折叠
所有分类 我的工作台
展开

“听红歌、学党史”——庆党100周年华诞

周志华 周志华 2021-06-30 17:05:15
0
0
简单

        2021年是党百年华诞。祖国站在“两个一百年”的历史交汇点,全面建设社会主义现代化国家新征程即将开启。100年风雨兼程,100年岁月如歌,在党的领导下,全国各族人民,艰苦奋战,建立了新中国。经过一代代前辈们的艰辛努力,饱经战乱屈辱与落后苦难的中华民族终于站起来了!中国就像一条巨龙,正以一个大国的身份重新屹立于世界东方。  

       本作品主要功能包含:1.听红歌,2.听党史故事,3.党史知识问答,望能以此作品庆祝党的100周年华诞,弘扬建党精神,通过听红歌、听党史故事等启迪引领我们青年人把自己的人生理想与祖国、时代、人类的命运联系起来,树立远大理想,培养良好品德,发扬创新精神,掌握实践能力,勤奋学习,立志成才,做新时代的社会主义事业的建设者和接班人。

步骤1 步骤1
1.电源制作。采用两节锂电池供电3.7V * 2 = 7.4V,通过开关接入并联排针,通过LM2596S降压模块,降压至5V,分别给各传感器、控制器供电,共使用两个LM2596S降压。
projectImage
步骤2 步骤2
2.选择控制器,采用Arduino主控板,共具备13个数字IO,6个模拟IO,一个硬件IIC,足够本次项目的主控板要求。
projectImage
步骤3 步骤3
3.按钮设计,共4个按钮,用于实现切换、选择、确认、返回等按钮功能需求,手头刚好有四个TTP223轻触按键。
projectImage
步骤4 步骤4
4.人机交互,采用0.96寸OLED显示器,采用IIC驱动方式,5V供电,可显示中文,但对于Arduino R3来说,flash较小,显示的中文汉字较多时,存储不了,因此易导致系统不稳定,在设计时需要注意,其实不考虑成本的情况下,可采用micro bit、掌控板或是ESP8266。
projectImage
步骤5 步骤5
5.语音播报采用mini player mp3播放模块,可直接驱动3W的扬声器,驱动方式可采用串口或是IO驱动。本次采用的软串口驱动,外接2W、8欧的扬声器。
projectImage
步骤6 步骤6
6.装饰物,可定做成天安门广场或红旗亚克力,本次由于成本问题,采用“乘风破浪”意义亚克力板,装饰效果不够明显,功能设计完整。
projectImage
步骤7 步骤7
7.整体外观效果如图。
projectImage
projectImage
材料清单 材料清单
1x
Arduino UNO R3主控板
1x
mini player播放器
1x
120M内存卡
1x
2W、8欧扬声器
1x
0.96寸OLED屏幕
2x
锂电池
1x
锂电池盒 * 2
4x
TTP223触摸轻触按键
2x
排针 * 16
2x
LM2596S-ADJ可调降压模块
1x
WS2812S灯带 * 6
代码 代码
	                    					#include <SimpleList.h>
#include <DFRobot_NeoPixel.h>
#include <DFRobot_SSD1306_I2C.h>
#include <DFRobot_PlayerMini.h>
#include <SoftwareSerial.h>

// 动态变量
volatile float     mind_n_BUT_C, mind_n_POS, mind_n_dis_one, mind_n_TiHao, mind_n_HuiDa,
                   mind_n_DeFen, mind_n_ins_flag, mind_n_T_flag;
SimpleList<String> mind_l_DaAn;
// 函数声明
void DF_ZhuYeMian();
void DF_ChuShiHua();
void DF_DangShiWenDaJiFenXiTong();
void DF_AnNiu();
void DF_GongNenSheJi();
void DF_DangShiWenDa();
void DF_DangShiMuLu();
void DF_HongGeMuLu();
void DF_XuanZeXianShi();
// 静态常量
const chCode chBuf[] = {
	{0x5e86,0xe5ba86,0xC7EC,{0x01,0x00,0x00,0x80,0x3f,0xfe,0x20,0x00,0x20,0x80,0x20,0x80,0x20,0x80,0x2f,0xfc,0x20,0x80,0x21,0x40,0x21,0x40,0x22,0x20,0x42,0x20,0x44,0x10,0x88,0x08,0x10,0x06}},
	{0x795d,0xe7a59d,0xD7A3,{0x20,0x00,0x13,0xfc,0x12,0x04,0xfa,0x04,0x0a,0x04,0x12,0x04,0x13,0xfc,0x38,0x90,0x54,0x90,0x94,0x90,0x10,0x90,0x11,0x12,0x11,0x12,0x12,0x12,0x14,0x0e,0x18,0x00}},
	{0x5efa,0xe5bbba,0xBDA8,{0x00,0x40,0x00,0x40,0xfb,0xf8,0x08,0x48,0x17,0xfe,0x10,0x48,0x23,0xf8,0x78,0x40,0x0b,0xf8,0x08,0x40,0x48,0x40,0x37,0xfc,0x10,0x40,0x2c,0x40,0x43,0xfe,0x80,0x00}},
	{0x515a,0xe5859a,0xB5B3,{0x01,0x00,0x11,0x10,0x09,0x10,0x09,0x20,0x7f,0xfe,0x40,0x02,0x80,0x04,0x1f,0xf0,0x10,0x10,0x10,0x10,0x1f,0xf0,0x04,0x40,0x04,0x40,0x08,0x42,0x30,0x42,0xc0,0x3e}},
	{0x5468,0xe591a8,0xD6DC,{0x00,0x00,0x3f,0xf8,0x21,0x08,0x21,0x08,0x2f,0xe8,0x21,0x08,0x21,0x08,0x3f,0xf8,0x20,0x08,0x27,0xc8,0x24,0x48,0x24,0x48,0x27,0xc8,0x40,0x08,0x40,0x28,0x80,0x10}},
	{0x5e74,0xe5b9b4,0xC4EA,{0x10,0x00,0x10,0x00,0x1f,0xfc,0x20,0x80,0x20,0x80,0x40,0x80,0x1f,0xf8,0x10,0x80,0x10,0x80,0x10,0x80,0xff,0xfe,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80}},
	{0x542c,0xe590ac,0xCCFD,{0x00,0x08,0x00,0x1c,0x79,0xe0,0x49,0x00,0x49,0x00,0x49,0x00,0x49,0xfe,0x49,0x10,0x49,0x10,0x49,0x10,0x79,0x10,0x49,0x10,0x01,0x10,0x02,0x10,0x02,0x10,0x04,0x10}},
	{0x7ea2,0xe7baa2,0xBAEC,{0x10,0x00,0x10,0x00,0x21,0xfc,0x24,0x20,0x44,0x20,0xf8,0x20,0x10,0x20,0x20,0x20,0x40,0x20,0xfc,0x20,0x40,0x20,0x00,0x20,0x1c,0x20,0xe0,0x20,0x43,0xfe,0x00,0x00}},
	{0x6b4c,0xe6ad8c,0xB8E8,{0x00,0x20,0xff,0x20,0x02,0x20,0x7a,0x7e,0x4a,0x42,0x7a,0x84,0x00,0x10,0xff,0x10,0x02,0x10,0x7a,0x10,0x4a,0x28,0x4a,0x28,0x7a,0x28,0x02,0x44,0x0a,0x44,0x04,0x82}},
	{0x53f2,0xe58fb2,0xCAB7,{0x01,0x00,0x01,0x00,0x01,0x00,0x3f,0xf8,0x21,0x08,0x21,0x08,0x21,0x08,0x3f,0xf8,0x21,0x08,0x01,0x00,0x11,0x00,0x09,0x00,0x06,0x00,0x05,0x80,0x18,0x70,0xe0,0x0e}},
	{0x6545,0xe69585,0xB9CA,{0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x80,0xfe,0xfe,0x11,0x08,0x12,0x88,0x10,0x88,0x7c,0x88,0x44,0x50,0x44,0x50,0x44,0x20,0x44,0x50,0x7c,0x88,0x45,0x04,0x02,0x02}},
	{0x4e8b,0xe4ba8b,0xCAC2,{0x01,0x00,0x01,0x00,0xff,0xfe,0x01,0x00,0x3f,0xf8,0x21,0x08,0x3f,0xf8,0x01,0x00,0x3f,0xf8,0x01,0x08,0xff,0xfe,0x01,0x08,0x3f,0xf8,0x01,0x00,0x05,0x00,0x02,0x00}},
	{0x77e5,0xe79fa5,0xD6AA,{0x20,0x00,0x20,0x00,0x20,0x7c,0x7e,0x44,0x48,0x44,0x88,0x44,0x08,0x44,0x08,0x44,0xff,0x44,0x08,0x44,0x14,0x44,0x14,0x44,0x22,0x7c,0x22,0x44,0x42,0x00,0x80,0x00}},
	{0x8bc6,0xe8af86,0xCAB6,{0x00,0x00,0x20,0x00,0x11,0xfc,0x11,0x04,0x01,0x04,0x01,0x04,0xf1,0x04,0x11,0x04,0x11,0xfc,0x11,0x04,0x10,0x00,0x14,0x90,0x18,0x88,0x11,0x04,0x02,0x02,0x04,0x02}},
	{0x95ee,0xe997ae,0xCECA,{0x20,0x00,0x17,0xfc,0x00,0x04,0x40,0x04,0x40,0x04,0x47,0xc4,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x47,0xc4,0x44,0x44,0x40,0x04,0x40,0x14,0x40,0x08}},
	{0x7b54,0xe7ad94,0xB4F0,{0x10,0x40,0x10,0x40,0x3f,0x7e,0x28,0x90,0x45,0x08,0x82,0x80,0x0c,0x60,0x30,0x18,0xcf,0xe6,0x00,0x00,0x1f,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0xf0,0x10,0x10}},
	{0xff1a,0xefbc9a,0xA3BA,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00}}
};
// 创建对象
DFRobot_SSD1306_I2C oled12864;
DFRobot_NeoPixel    neoPixel_8;
DFRobot_PlayerMini  mp3;
SoftwareSerial      softSerialmp3(2, 3);


// 主程序开始
void setup() {
	oled12864.setChCode(chBuf);
	DF_ChuShiHua();
}
void loop() {
	DF_XuanZeXianShi();
	DF_AnNiu();
	if (((mind_n_BUT_C==1) && (!((mind_n_POS - mind_n_dis_one)==0)))) {
		oled12864.fillScreen(0);
		DF_HongGeMuLu();
	}
	else if (((mind_n_BUT_C==2) && (!((mind_n_POS - mind_n_dis_one)==0)))) {
		oled12864.fillScreen(0);
		DF_DangShiMuLu();
	}
	else if (((mind_n_BUT_C==3) && (!((mind_n_POS - mind_n_dis_one)==0)))) {
		oled12864.fillScreen(0);
		DF_DangShiWenDa();
	}
	mind_n_dis_one = mind_n_POS;
}


// 自定义函数
void DF_ZhuYeMian() {
	oled12864.setCursor(7, 0);
	oled12864.print("庆祝建党100周年");
	oled12864.setCursorLine(2);
	oled12864.printLine("1.听红歌");
	oled12864.setCursorLine(3);
	oled12864.printLine("2.听党史故事");
	oled12864.setCursorLine(4);
	oled12864.printLine("3.知识问答");
}
void DF_ChuShiHua() {
	neoPixel_8.begin(8, 6);
	neoPixel_8.setBrightness(255);
	neoPixel_8.setRangeColor(0, 6, 0xFF0000);
	oled12864.begin(0x3c);
	mp3.begin(&softSerialmp3);
	mp3.volume(100);
	mp3.playMp3Folder(13);
	DF_ZhuYeMian();
	mind_n_TiHao = 0;
	mind_n_HuiDa = 0;
	mind_n_DeFen = 0;
	mind_n_ins_flag = 0;
	mind_n_POS = 0;
	mind_n_BUT_C = 0;
	mind_n_dis_one = 0;
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("1");
	mind_l_DaAn.push_back("2");
	mind_l_DaAn.push_back("1");
}
void DF_DangShiWenDaJiFenXiTong() {
	if (((String(mind_l_DaAn[mind_n_TiHao-1]).toInt())==mind_n_HuiDa)) {
		mind_n_DeFen += 10;
	}
	else {
		if ((mind_n_HuiDa==1)) {
			mp3.playMp3Folder(35);
		}
		else {
			mp3.playMp3Folder(34);
		}
	}
	mind_n_dis_one = 10;
	mind_n_T_flag = mind_n_TiHao;
}
void DF_AnNiu() {
	if (digitalRead(5)) {
		mind_n_POS -= 1;
		if ((mind_n_POS<=0)) {
			mind_n_POS = 0;
		}
		if (((mind_n_BUT_C==3) && (!(mind_n_T_flag==mind_n_TiHao)))) {
			mind_n_HuiDa = 1;
			DF_DangShiWenDaJiFenXiTong();
		}
		while (!(!digitalRead(5))) {}
	}
	else if (digitalRead(4)) {
		mind_n_POS += 1;
		if (((mind_n_BUT_C==3) && (!(mind_n_T_flag==mind_n_TiHao)))) {
			mind_n_HuiDa = 2;
			DF_DangShiWenDaJiFenXiTong();
		}
		while (!(!digitalRead(4))) {}
	}
	if ((mind_n_BUT_C==1)) {
		mind_n_POS = (((int)mind_n_POS) % ((int)16));
	}
	else if ((mind_n_BUT_C==2)) {
		mind_n_POS = (((int)mind_n_POS) % ((int)7));
	}
	else if ((mind_n_BUT_C==3)) {
		mind_n_POS = 0;
	}
	else {
		mind_n_POS = (((int)mind_n_POS) % ((int)4));
	}
	mind_n_ins_flag = (((int)mind_n_POS) % ((int)4));
	if (digitalRead(6)) {
		if (((mind_n_POS==1) && (!(((mind_n_BUT_C==1) || (mind_n_BUT_C==2)) || (mind_n_BUT_C==3))))) {
			mind_n_POS = 0;
			mind_n_BUT_C = 1;
		}
		else if (((mind_n_POS==2) && (!(((mind_n_BUT_C==1) || (mind_n_BUT_C==2)) || (mind_n_BUT_C==3))))) {
			mind_n_POS = 0;
			mind_n_BUT_C = 2;
		}
		else if ((((mind_n_POS==3) && (!((mind_n_BUT_C==1) || (mind_n_BUT_C==2)))) || (mind_n_BUT_C==3))) {
			mind_n_TiHao += 1;
			mind_n_BUT_C = 3;
			mind_n_POS = 0;
		}
		DF_GongNenSheJi();
		while (!(!digitalRead(6))) {}
	}
	if (digitalRead(7)) {
		oled12864.fillScreen(0);
		mind_n_TiHao = 0;
		mind_n_DeFen = 0;
		mind_n_dis_one = 0;
		mind_n_T_flag = 0;
		mind_n_ins_flag = 0;
		mind_n_POS = 0;
		mind_n_BUT_C = 0;
		DF_ZhuYeMian();
		mp3.stop();
		while (!(!digitalRead(7))) {}
	}
}
void DF_GongNenSheJi() {
	if ((mind_n_BUT_C==1)) {
		if ((mind_n_POS==1)) {
			mp3.playMp3Folder(1);
		}
		else if ((mind_n_POS==2)) {
			mp3.playMp3Folder(2);
		}
		else if ((mind_n_POS==3)) {
			mp3.playMp3Folder(3);
		}
		else if ((mind_n_POS==5)) {
			mp3.playMp3Folder(4);
		}
		else if ((mind_n_POS==6)) {
			mp3.playMp3Folder(5);
		}
		else if ((mind_n_POS==7)) {
			mp3.playMp3Folder(6);
		}
		else if ((mind_n_POS==9)) {
			mp3.playMp3Folder(7);
		}
		else if ((mind_n_POS==10)) {
			mp3.playMp3Folder(8);
		}
		else if ((mind_n_POS==11)) {
			mp3.playMp3Folder(9);
		}
		else if ((mind_n_POS==13)) {
			mp3.playMp3Folder(10);
		}
		else if ((mind_n_POS==14)) {
			mp3.playMp3Folder(11);
		}
		else if ((mind_n_POS==15)) {
			mp3.playMp3Folder(12);
		}
	}
	if ((mind_n_BUT_C==2)) {
		if ((mind_n_POS==1)) {
			mp3.playMp3Folder(14);
		}
		else if ((mind_n_POS==2)) {
			mp3.playMp3Folder(15);
		}
		else if ((mind_n_POS==3)) {
			mp3.playMp3Folder(16);
		}
		else if ((mind_n_POS==5)) {
			mp3.playMp3Folder(17);
		}
		else if ((mind_n_POS==6)) {
			mp3.playMp3Folder(18);
		}
	}
	if ((mind_n_BUT_C==3)) {
		if ((mind_n_TiHao==1)) {
			mp3.playMp3Folder(19);
		}
		else if ((mind_n_TiHao==2)) {
			mp3.playMp3Folder(20);
		}
		else if ((mind_n_TiHao==3)) {
			mp3.playMp3Folder(21);
		}
		else if ((mind_n_TiHao==4)) {
			mp3.playMp3Folder(22);
		}
		else if ((mind_n_TiHao==5)) {
			mp3.playMp3Folder(23);
		}
		else if ((mind_n_TiHao==6)) {
			mp3.playMp3Folder(24);
		}
		else if ((mind_n_TiHao==7)) {
			mp3.playMp3Folder(25);
		}
		else if ((mind_n_TiHao==8)) {
			mp3.playMp3Folder(26);
		}
		else if ((mind_n_TiHao==9)) {
			mp3.playMp3Folder(27);
		}
		else if ((mind_n_TiHao==10)) {
			mp3.playMp3Folder(28);
		}
		else if ((mind_n_TiHao==11)) {
			mp3.playMp3Folder(29);
		}
		else if ((mind_n_TiHao==12)) {
			mp3.playMp3Folder(30);
		}
		else if ((mind_n_TiHao==13)) {
			mp3.playMp3Folder(31);
		}
		else if ((mind_n_TiHao==14)) {
			mp3.playMp3Folder(32);
		}
		else if ((mind_n_TiHao==15)) {
			mp3.playMp3Folder(33);
		}
	}
}
void DF_DangShiWenDa() {
	oled12864.setCursor(32, 0);
	oled12864.print("党史问答");
	oled12864.setCursor(0, 1);
	oled12864.print("Listen question:");
	oled12864.setCursorLine(3);
	oled12864.printLine("Select: A or B");
	oled12864.setCursorLine(4);
	oled12864.printLine("Score:");
	oled12864.setCursor(56, 3);
	oled12864.print(mind_n_DeFen);
}
void DF_DangShiMuLu() {
	oled12864.setCursor(22, 0);
	oled12864.print("党史故事");
	if ((mind_n_POS<4)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("1.May 4th  ...");
		oled12864.setCursorLine(3);
		oled12864.printLine("2.The first...   ");
		oled12864.setCursorLine(4);
		oled12864.printLine("3.Brewing  ...    ");
	}
	else if ((mind_n_POS<8)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("4.A grand  ...");
		oled12864.setCursorLine(3);
		oled12864.printLine("5.The climax...");
	}
}
void DF_HongGeMuLu() {
	oled12864.setCursor(42, 0);
	oled12864.print("听红歌");
	if ((mind_n_POS<4)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("1.Without...");
		oled12864.setCursorLine(3);
		oled12864.printLine("2.Sing a ...   ");
		oled12864.setCursorLine(4);
		oled12864.printLine("3.Party  ...    ");
	}
	else if ((mind_n_POS<8)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("4.Dedicate...");
		oled12864.setCursorLine(3);
		oled12864.printLine("5.Nanniwan...");
		oled12864.setCursorLine(4);
		oled12864.printLine("6.Remain  ...   ");
	}
	else if ((mind_n_POS<12)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("7.Hongmeizan..");
		oled12864.setCursorLine(3);
		oled12864.printLine("8.My mother...");
		oled12864.setCursorLine(4);
		oled12864.printLine("9.The rising..");
	}
	else if ((mind_n_POS<16)) {
		oled12864.setCursorLine(2);
		oled12864.printLine("10.Oriental...");
		oled12864.setCursorLine(3);
		oled12864.printLine("11.Singing ...");
		oled12864.setCursorLine(4);
		oled12864.printLine("12.follow  ...");
	}
}
void DF_XuanZeXianShi() {
	if ((!(mind_n_BUT_C==3))) {
		if ((mind_n_ins_flag==1)) {
			oled12864.setCursor(110, 1);
			oled12864.print("<<");
			oled12864.setCursor(110, 2);
			oled12864.print("  ");
			oled12864.setCursor(110, 3);
			oled12864.print("  ");
		}
		else if ((mind_n_ins_flag==2)) {
			oled12864.setCursor(110, 1);
			oled12864.print("  ");
			oled12864.setCursor(110, 2);
			oled12864.print("<<");
			oled12864.setCursor(110, 3);
			oled12864.print("  ");
		}
		else if ((mind_n_ins_flag==3)) {
			oled12864.setCursor(110, 1);
			oled12864.print("  ");
			oled12864.setCursor(110, 2);
			oled12864.print("  ");
			oled12864.setCursor(110, 3);
			oled12864.print("<<");
		}
		else {
			oled12864.setCursor(110, 1);
			oled12864.print("  ");
			oled12864.setCursor(110, 2);
			oled12864.print("  ");
			oled12864.setCursor(110, 3);
			oled12864.print("  ");
		}
	}
}
	                    				
Makelog作者原创文章,未经授权禁止转载。
0
0
评论
[[c.user_name]] [[c.create_time]]
[[c.parent_comment.count]]
|
[[c.comment_content]]