感谢感谢。
代码放最后 AWA 代码有点长,所以放在了最后 : )
材料表(主要材料)
序号 | 名称 | 规格 |
1 | ESP32开发板 | 看着买 |
2 | HX711模块 | 推荐买紫色或红色款的 |
3 | 继电器 | 3V/5v 5/4引脚 建议不要买常开型 |
4 | 蜂鸣器 | 无源 |
5 | TF卡模块 | 带电平转换芯片 |
本采集卡使用ESP32 作为主控 arduino进行开发
明天开学力,电脑要没收了 : (
祝大家开学快乐 : )
拆解前
拆解后 (用TIM编辑的图片不知道为什么,字变小了 )
由于我没有3v的继电器,所以弄了个升压板,如果购买的是3v/5v继电器就可以不用了 : )
由于继电器有4角5脚的,常闭,常开的,所以在接继电器的时,要看好下图的接线图,图中举出了3种继电器接线方法,接线时 请认真看好,否则可能出现上电就点火的危险情况!!!认真看好!!!
接线图(手画的 不太好 见谅)
蓝牙命令(使用蓝牙串口调试助手) 以下命令可在程序中自定义 : )
在执行 music,Fire命令时,发送任何字符即可打断命令
music 播放音乐(从上一次打断的音符开始播放)
Fire 点火 (输入后,根据提示输入倒计时时间)
STOP 重启采集卡
演示视频 :
202408311705.mp4 点击下载
使用方法见上
以下是采集卡代码(音乐是 熙熙攘攘我们的城市)如果不喜欢的话可以删去,希望可以先听一听: )
音乐播放效果,去听一听嘛 : )点我!点我!(去听蜂鸣器音乐)
好了 接线图和代码都放出来了 明天开学力 祝大家 天天向上 开学快乐! : )
#include <Arduino.h> #include <string> #include <iostream> #include <sstream> #include <SPI.h> #include <SD.h> #include <FS.h> #include <HX711.h> #include <BluetoothSerial.h> //music是移植过来的,直接删掉也没问题的哟~ //~~~~~~~~~~music~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int yesterday=0; const int buzzer=15; typedef struct data{ note_t yinfu; uint16_t yingao; uint16_t shichang; }note; note melody[]={ {NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_D,4,150},{NOTE_D,4,150},{NOTE_C,4,250},{NOTE_G,3,250},{NOTE_A,3,250},{NOTE_G,3,250},{NOTE_E,3,250}, {NOTE_A,3,250},{NOTE_E,4,150},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_D,4,150},{NOTE_D,4,150},{NOTE_D,4,150},{NOTE_C,4,250},{NOTE_C,4,150},{NOTE_A,3,250},{NOTE_A,3,150},{NOTE_G,3,250},{NOTE_E,3,250}, {NOTE_A,3,250},{NOTE_G,4,150},{NOTE_G,4,250},{NOTE_E,4,150},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_E,4,150},{NOTE_E,4,150},{NOTE_D,4,150},{NOTE_E,4,250},{NOTE_D,4,150},{NOTE_E,4,250},{NOTE_D,4,150},{NOTE_E,4,500}, {NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250}, {NOTE_G,4,250},{NOTE_D,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_G,3,125},{NOTE_A,3,125}, {NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_E,4,250}, {NOTE_E,4,250},{NOTE_D,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,250},{NOTE_A,3,500},{NOTE_C,5,125},{NOTE_B,4,125},{NOTE_G,4,125}, {NOTE_E,4,125},{NOTE_E,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_C,3,125},{NOTE_B,4,125},{NOTE_G,4,125},{NOTE_E,4,125}, {NOTE_E,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_A,4,125},{NOTE_G,4,125},{NOTE_A,4,125},{NOTE_B,4,125},{NOTE_C,5,125}, {NOTE_D,5,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_D,5,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_G,5,125},{NOTE_F,5,125},{NOTE_E,5,125}, {NOTE_D,5,125},{NOTE_C,5,125},{NOTE_A,5,125},{NOTE_G,5,125},{NOTE_A,5,125},{NOTE_B,5,125},{NOTE_C,6,125},{NOTE_B,5,125},{NOTE_C,6,125}, {NOTE_D,6,125},{NOTE_E,6,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_G,6,125},{NOTE_G,6,125},{NOTE_E,6,125},{NOTE_D,6,125},{NOTE_C,6,125}, {NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_A,5,125},{NOTE_G,6,125},{NOTE_A,6,125}, {NOTE_E,6,125},{NOTE_G,6,125},{NOTE_A,6,125},{NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,250}, {NOTE_E,3,250},{NOTE_E,3,125},{NOTE_E,3,250},{NOTE_D,3,250},{NOTE_E,3,250},{NOTE_G,3,250},{NOTE_G,3,500}, {NOTE_E,3,250},{NOTE_F,3,250},{NOTE_G,3,250},{NOTE_G,3,125},{NOTE_G,3,250},{NOTE_F,3,250},{NOTE_E,3,250}, {NOTE_D,3,250},{NOTE_D,3,250},{NOTE_E,3,125},{NOTE_E,3,250},{NOTE_F,3,250},{NOTE_E,3,500},{NOTE_E,3,250}, {NOTE_E,3,125},{NOTE_E,3,125},{NOTE_D,3,250},{NOTE_E,3,250},{NOTE_F,3,250},{NOTE_G,3,500},{NOTE_E,3,250}, {NOTE_F,3,250},{NOTE_G,3,250},{NOTE_G,3,125},{NOTE_G,3,250},{NOTE_C,4,250},{NOTE_B,3,250},{NOTE_G,3,250}, {NOTE_D,4,250},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,500},{NOTE_E,4,250},{NOTE_E,4,125}, {NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_A,3,250},{NOTE_B,3,250},{NOTE_G,3,250}, {NOTE_G,3,250},{NOTE_A,3,500},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_G,3,250},{NOTE_E,4,500},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_A,3,250},{NOTE_B,3,250},{NOTE_G,3,250},{NOTE_G,3,250},{NOTE_A,3,500},{NOTE_C,4,250},{NOTE_C,4,250}, {NOTE_C,4,250},{NOTE_G,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_D,4,500},{NOTE_D,4,500},{NOTE_E,4,500}, {NOTE_G,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_E,3,125},{NOTE_G,3,125}, {NOTE_E,3,125},{NOTE_E,3,125},{NOTE_A,3,250},{NOTE_D,3,250},{NOTE_E,3,250},{NOTE_A,4,250},{NOTE_C,5,250}, {NOTE_D,5,250},{NOTE_A,4,250},{NOTE_E,5,125},{NOTE_G,5,125},{NOTE_E,5,125},{NOTE_C,5,125},{NOTE_C,5,250}, {NOTE_D,5,250},{NOTE_A,3,250},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_E,3,125},{NOTE_G,3,250}, {NOTE_E,3,125},{NOTE_D,3,250},{NOTE_D,3,250},{NOTE_E,3,250},{NOTE_C,6,250},{NOTE_B,5,250},{NOTE_G,5,250}, {NOTE_E,5,250},{NOTE_D,5,125},{NOTE_C,5,125},{NOTE_D,5,125},{NOTE_A,5,125},{NOTE_A,3,250},{NOTE_B,3,250}, {NOTE_C,4,250},{NOTE_B,3,125},{NOTE_G,3,125},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_E,3,250},{NOTE_E,3,250}, {NOTE_E,3,250},{NOTE_C,4,250},{NOTE_B,3,125},{NOTE_G,3,125},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_A,3,250}, {NOTE_A,3,250},{NOTE_A,3,250},{NOTE_D,4,250},{NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,125}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_E,4,125}, {NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_B,3,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_C,4,250}, {NOTE_D,4,250},{NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_C,4,250},{NOTE_D,4,250},{NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_C,4,125},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_G,4,250},{NOTE_G,4,500},{NOTE_A,4,500}, {NOTE_G,4,500},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,250}, {NOTE_C,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_C,4,500}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,250},{NOTE_G,4,250},{NOTE_C,4,500},{NOTE_E,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_E,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_D,4,250},{NOTE_D,4,125},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_C,4,250},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_D,4,125}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,500},{NOTE_C,4,125},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_G,4,250}, {NOTE_G,4,500},{NOTE_G,4,125},{NOTE_A,4,125},{NOTE_G,4,250},{NOTE_G,4,500},{NOTE_E,4,250},{NOTE_E,4,125}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_D,4,250},{NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,250},{NOTE_G,4,250}, {NOTE_C,4,500},{NOTE_E,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_G,4,250}, {NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125}, {NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_C,4,125},{NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,250}, {NOTE_E,3,250},{NOTE_A,3,250},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250}, {NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_C,4,125}, {NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,250},{NOTE_E,3,250},{NOTE_A,3,250},{NOTE_G,4,125},{NOTE_G,4,250}, {NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_E,4,125}, {NOTE_D,4,125},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,500},{NOTE_E,4,250}, {NOTE_D,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_G,4,250},{NOTE_D,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,250}, {NOTE_A,3,250},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_A,3,125}, {NOTE_G,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,250},{NOTE_A,3,500},{NOTE_C,5,125},{NOTE_B,4,125},{NOTE_G,4,125}, {NOTE_E,4,125},{NOTE_D,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_C,5,125},{NOTE_B,4,125}, {NOTE_G,4,125},{NOTE_E,4,125},{NOTE_D,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_A,4,125}, {NOTE_G,4,125},{NOTE_A,4,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_D,5,125},{NOTE_B,4,125},{NOTE_C,5,125}, {NOTE_D,5,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_G,5,125},{NOTE_F,5,125},{NOTE_E,5,125},{NOTE_D,5,125}, {NOTE_C,5,125},{NOTE_A,5,125},{NOTE_G,5,125},{NOTE_A,5,125},{NOTE_B,5,125},{NOTE_C,6,125},{NOTE_B,6,125}, {NOTE_C,6,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_G,6,125},{NOTE_G,6,125}, {NOTE_E,6,125},{NOTE_D,6,125},{NOTE_C,6,125},{NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_A,5,125}, {NOTE_D,6,125},{NOTE_E,6,125},{NOTE_A,5,125},{NOTE_G,6,125},{NOTE_A,6,125},{NOTE_E,6,125},{NOTE_G,6,125}, {NOTE_A,6,125},{NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,250},{NOTE_E,3,500},{NOTE_E,3,250},{NOTE_D,3,250}, {NOTE_E,3,250},{NOTE_F,3,250},{NOTE_G,3,500},{NOTE_E,3,250},{NOTE_F,3,250},{NOTE_G,3,250},{NOTE_G,3,125}, {NOTE_G,3,250},{NOTE_F,3,250},{NOTE_E,3,250},{NOTE_D,3,250},{NOTE_D,3,250},{NOTE_E,3,125},{NOTE_E,3,250}, {NOTE_F,3,250},{NOTE_E,3,500},{NOTE_E,3,250},{NOTE_E,3,125},{NOTE_E,3,125},{NOTE_D,3,250},{NOTE_E,3,250}, {NOTE_G,3,250},{NOTE_G,3,500},{NOTE_E,3,250},{NOTE_F,3,250},{NOTE_G,3,250},{NOTE_G,3,125},{NOTE_G,3,250}, {NOTE_C,4,250},{NOTE_B,3,250},{NOTE_G,3,250},{NOTE_D,4,250},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_E,4,500},{NOTE_E,4,500},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_B,3,500}, {NOTE_G,3,250},{NOTE_G,3,250},{NOTE_A,3,500},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_E,4,500},{NOTE_E,3,250},{NOTE_E,4,500},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_B,3,500},{NOTE_G,3,250},{NOTE_G,3,250},{NOTE_A,3,500},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_C,4,250}, {NOTE_G,4,250},{NOTE_D,4,1000},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_G,3,125}, {NOTE_A,3,125},{NOTE_A,3,125},{NOTE_E,3,125},{NOTE_G,3,250},{NOTE_D,3,125},{NOTE_E,3,250},{NOTE_A,2,125}, {NOTE_D,3,250},{NOTE_E,3,250},{NOTE_A,4,250},{NOTE_C,5,250},{NOTE_D,5,250},{NOTE_A,4,250},{NOTE_E,5,125}, {NOTE_G,5,125},{NOTE_E,5,125},{NOTE_C,5,125},{NOTE_C,5,250},{NOTE_D,5,250},{NOTE_A,3,250},{NOTE_G,3,125}, {NOTE_A,3,125},{NOTE_A,3,125},{NOTE_E,3,125},{NOTE_G,3,250},{NOTE_D,3,125},{NOTE_E,3,125},{NOTE_D,3,250}, {NOTE_D,3,250},{NOTE_E,3,250},{NOTE_C,6,250},{NOTE_B,5,250},{NOTE_G,5,250},{NOTE_E,5,250},{NOTE_D,5,125}, {NOTE_C,5,125},{NOTE_D,5,125},{NOTE_A,5,125},{NOTE_A,3,250},{NOTE_B,3,250},{NOTE_C,4,250},{NOTE_B,3,125}, {NOTE_G,3,125},{NOTE_G,3,125},{NOTE_A,3,125},{NOTE_E,3,250},{NOTE_E,3,250},{NOTE_E,3,250},{NOTE_C,4,250}, {NOTE_C,3,125},{NOTE_B,3,125},{NOTE_G,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_A,3,250},{NOTE_A,3,250}, {NOTE_A,4,250},{NOTE_D,4,125},{NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_C,4,500},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_E,4,250}, {NOTE_E,4,250},{NOTE_D,4,250},{NOTE_B,3,250},{NOTE_D,4,250},{NOTE_E,4,500},{NOTE_D,4,500},{NOTE_E,4,250}, {NOTE_F,4,125},{NOTE_F,4,250},{NOTE_E,4,250},{NOTE_D,4,500},{NOTE_E,4,1500},{NOTE_E,4,2000},{NOTE_B,3,250}, {NOTE_G,3,250},{NOTE_B,3,250},{NOTE_C,4,250},{NOTE_B,3,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_E,4,250},{NOTE_D,4,125},{NOTE_C,4,125},{NOTE_E,4,250},{NOTE_A,4,250},{NOTE_G,4,250},{NOTE_E,4,250}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_A,3,250},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_B,3,125},{NOTE_B,3,250},{NOTE_G,3,250},{NOTE_C,4,250},{NOTE_G,4,125},{NOTE_G,4,250},{NOTE_F,4,250}, {NOTE_E,4,250},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_C,4,250},{NOTE_G,3,250},{NOTE_C,4,250}, {NOTE_E,4,250},{NOTE_G,4,250},{NOTE_E,4,250},{NOTE_B,3,250},{NOTE_D,4,500},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_C,4,250}, {NOTE_D,4,250},{NOTE_C,4,125},{NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_C,4,125},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_G,4,250},{NOTE_G,4,500},{NOTE_A,4,500},{NOTE_G,4,500}, {NOTE_E,4,250},{NOTE_E,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,250}, {NOTE_C,4,250},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_D,4,250}, {NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,250},{NOTE_G,4,250},{NOTE_C,4,500},{NOTE_E,4,500},{NOTE_D,4,250},{NOTE_E,4,250}, {NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_D,4,250},{NOTE_D,4,125}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_C,4,250},{NOTE_D,4,125},{NOTE_C,4,250}, {NOTE_D,4,125},{NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,500},{NOTE_C,4,125},{NOTE_E,4,125},{NOTE_E,4,250}, {NOTE_G,4,250},{NOTE_G,4,500},{NOTE_G,4,125},{NOTE_A,4,250},{NOTE_G,4,500},{NOTE_E,4,250},{NOTE_E,4,125}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_C,4,250},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_D,4,250},{NOTE_C,4,500},{NOTE_C,4,125},{NOTE_C,4,125}, {NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,125},{NOTE_C,4,250},{NOTE_G,4,250}, {NOTE_C,4,500},{NOTE_E,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_G,4,250}, {NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125}, {NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_C,4,125},{NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,250}, {NOTE_E,3,250},{NOTE_A,3,250},{NOTE_E,4,125},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250}, {NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_D,4,125},{NOTE_C,4,250},{NOTE_C,4,125}, {NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,250},{NOTE_E,3,250},{NOTE_A,3,250},{NOTE_G,4,125},{NOTE_G,4,250}, {NOTE_E,4,250},{NOTE_A,3,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_E,4,125},{NOTE_E,4,125}, {NOTE_D,4,125},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,500},{NOTE_E,4,250}, {NOTE_D,4,125},{NOTE_E,4,125},{NOTE_E,4,125},{NOTE_D,4,125},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_G,4,250},{NOTE_D,4,500},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_D,4,125},{NOTE_E,4,250}, {NOTE_A,3,250},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_A,3,125}, {NOTE_G,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_E,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_D,4,250},{NOTE_C,4,250},{NOTE_E,4,250},{NOTE_A,3,500},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_G,3,250}, {NOTE_A,3,250},{NOTE_E,4,250},{NOTE_A,3,250},{NOTE_G,3,250},{NOTE_A,3,250},{NOTE_A,3,250},{NOTE_E,4,250}, {NOTE_E,5,250},{NOTE_D,5,250},{NOTE_C,5,250},{NOTE_B,4,250},{NOTE_G,4,250},{NOTE_A,3,250},{NOTE_A,3,125}, {NOTE_A,3,125},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,250},{NOTE_A,3,125},{NOTE_G,3,125},{NOTE_A,3,125}, {NOTE_G,3,125},{NOTE_A,3,250},{NOTE_F,4,125},{NOTE_G,4,125},{NOTE_G,4,250},{NOTE_E,4,250},{NOTE_D,4,250}, {NOTE_C,4,250},{NOTE_E,4,500},{NOTE_A,3,500},{NOTE_C,5,125},{NOTE_B,4,125},{NOTE_G,4,125},{NOTE_E,4,125}, {NOTE_E,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_C,5,125},{NOTE_B,4,125},{NOTE_G,4,125}, {NOTE_E,4,125},{NOTE_E,4,125},{NOTE_G,4,125},{NOTE_D,4,125},{NOTE_E,4,125},{NOTE_A,4,125},{NOTE_G,4,125}, {NOTE_A,4,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_D,5,125},{NOTE_B,4,125},{NOTE_C,5,125},{NOTE_D,5,125}, {NOTE_B,4,125},{NOTE_C,5,125},{NOTE_G,5,125},{NOTE_F,5,125},{NOTE_E,5,125},{NOTE_D,5,125},{NOTE_C,5,125}, {NOTE_A,5,125},{NOTE_G,5,125},{NOTE_A,5,125},{NOTE_B,5,125},{NOTE_C,6,125},{NOTE_B,5,125},{NOTE_C,6,125}, {NOTE_D,6,125},{NOTE_E,6,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_G,6,125},{NOTE_G,6,125},{NOTE_E,6,125}, {NOTE_D,6,125},{NOTE_C,6,125},{NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,125},{NOTE_A,5,125},{NOTE_D,6,125}, {NOTE_E,6,125},{NOTE_A,5,125},{NOTE_G,6,125},{NOTE_A,6,125},{NOTE_E,6,125},{NOTE_G,6,125},{NOTE_A,6,125}, {NOTE_A,5,125},{NOTE_D,6,125},{NOTE_E,6,250},{NOTE_C,5,250},{NOTE_B,4,250},{NOTE_G,4,250},{NOTE_A,4,250}, {NOTE_E,4,250},{NOTE_G,4,250},{NOTE_D,4,250},{NOTE_E,4,250},{NOTE_C,4,250},{NOTE_D,4,250},{NOTE_B,3,250}, {NOTE_C,4,250},{NOTE_G,3,250},{NOTE_B,3,250},{NOTE_E,3,250},{NOTE_G,3,250},{NOTE_A,3,500},{NOTE_E,4,500}, {NOTE_D,4,500},{NOTE_E,4,500},{NOTE_B,3,500},{NOTE_A,3,500},{NOTE_C,4,500},{NOTE_D,4,500},{NOTE_E,4,500}, {NOTE_G,4,500},{NOTE_A,4,500} }; uint16_t tonesize = sizeof(melody)/sizeof(note); //~~~~~~~~~~music~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //music是移植过来的,直接删掉也没问题的哟~ const int LOADCELL_DOUT_PIN = 34;//对应HX711模块的DO引脚 const int LOADCELL_SCK_PIN = 4;//对应HX711模块的CK引脚 const int SENSOR_CALIBRATION = -23.8846;//传感器校准值 const int TF_MOSI_PIN = 23;//对应TF卡模块的MOSI引脚 const int TF_MISO_PIN = 19;//对应TF卡模块的MISO引脚 const int TF_SCK_PIN = 18;//对应TF卡模块的SCK引脚 const int TF_CS_PIN = 5;//对应TF卡模块的CS引脚 const int LED_PIN = 2;//板载led const int BUZZER_PIN = 15;//蜂鸣器引脚 const int FIRE_PIN = 27;//继电器引脚 int fire_time=10; //int key[] = {6,7,4,2,1,3,5}; std::string BTdata; String BTData; HX711 scale; //File TF_password; File TF; BluetoothSerial SerialBT; SPIClass CustomSPI; /* void Password(std::string& c,int kry[]){ int len = c.size(); for(int i = 0;i < len;i++){ c[i] = c[i] ^ key[i % 7]; } } */ void HX711_init(){ scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); scale.set_gain(128); scale.set_scale(SENSOR_CALIBRATION); scale.tare(); } void HX711_read(){ TF.println(scale.get_units()); } void BT_init(){ SerialBT.begin("无线试车台V2_by_bbbbmmdddd"); } void Fire(bool a){ if(a==1){ digitalWrite(FIRE_PIN,LOW); } else if(a==0){ digitalWrite(FIRE_PIN,HIGH); } } void led(bool a){ if(a==1){ digitalWrite(LED_PIN,HIGH); } else if(a==0){ digitalWrite(LED_PIN,LOW); } } void times(int time){ for(int i=0;i<time && !SerialBT.available();i++){ delay(400); if(time > 1){ String time1="倒计时"+ String(time-i) + "秒"; SerialBT.println(time1); tone(BUZZER_PIN,988); delay(100); noTone(BUZZER_PIN); led(1); delay(500); led(0); } else{ SerialBT.println("点火!"); } } } void TF_init(){ CustomSPI.begin(TF_SCK_PIN, TF_MISO_PIN, TF_MOSI_PIN, TF_CS_PIN); pinMode(TF_CS_PIN,OUTPUT); } void setup() { pinMode(FIRE_PIN,OUTPUT); digitalWrite(FIRE_PIN,HIGH); pinMode(BUZZER_PIN, OUTPUT); pinMode(LED_PIN,OUTPUT); tone(BUZZER_PIN,532); delay(100); tone(BUZZER_PIN,587); delay(100); tone(BUZZER_PIN,659); delay(300); noTone(BUZZER_PIN); HX711_init(); BT_init(); TF_init(); Serial.begin(115200); if(!SD.begin(TF_CS_PIN,CustomSPI, 1000000)){ SerialBT.println("TF卡初始化失败!"); tone(BUZZER_PIN,988); delay(3000); noTone(BUZZER_PIN); } else{ SerialBT.println("TF卡初始化成功!"); } TF = SD.open("/thrust.txt",FILE_WRITE); if(TF){ TF.println("欢迎使用无线试车台V1.2_by:bbbbmmdddd"); TF.close(); } else { tone(BUZZER_PIN,988); delay(500); tone(BUZZER_PIN,988); delay(500); noTone(BUZZER_PIN); } //TF_password = SD.open("password.txt",FILE_WRITE); //SerialBT.println("欢迎使用无线试车台V1.2 请输入密码:"); } //~~~~~~~~~~music~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void music(){ ledcSetup(0,20000,10); ledcAttachPin(buzzer,0); for(int i=yesterday;i<tonesize;i++){ ledcWriteNote(0,melody[i].yinfu,melody[i].yingao); delay(melody[i].shichang*0.77); yesterday=i; if(SerialBT.available()){ break; } } if(yesterday >= tonesize-1){ yesterday = 0; } delay(300); tone(BUZZER_PIN,988); delay(100); noTone(BUZZER_PIN); ledcWrite(0,0); } //~~~~~~~~~~music~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~music~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void CallBTData(String Data ); void loop() { if(SerialBT.available()) { BTData = SerialBT.readStringUntil('\xff'); SerialBT.println(BTData);//测试 CallBTData(BTData); } } void CallBTData(String Data ){ if(Data.substring(0,3) == "hello"){ SerialBT.println("未定义功能"); } else if(Data.substring(0,3) == "hello"){ SerialBT.println("未定义功能"); } else if(Data.substring(0,5) == "music"){ SerialBT.println("已获取记录,播放中"); music(); } else if(Data.substring(0,4) == "STOP"){ SerialBT.println("复位中..."); tone(BUZZER_PIN,659); led(1); delay(100); tone(BUZZER_PIN,587); led(0); delay(100); tone(BUZZER_PIN,532); delay(300); ESP.restart(); } else if(Data.substring(0,4) == "Fire"){ tone(BUZZER_PIN,988); delay(200); tone(BUZZER_PIN,988); delay(200); noTone(BUZZER_PIN); SerialBT.println("请输入倒计时时间(单位秒)"); while(!SerialBT.available()){ delay(100); } BTData = SerialBT.readStringUntil('\xff'); fire_time = BTData.toInt(); times(fire_time); tone(BUZZER_PIN,988); delay(1000); noTone(BUZZER_PIN); Fire(1); SerialBT.println("开始采集!"); led(1); TF = SD.open("/thrust.txt",FILE_WRITE); while(!SerialBT.available()){ HX711_read(); } Fire(0); TF.close(); SerialBT.println("关闭采集!"); led(0); tone(BUZZER_PIN,659); delay(100); noTone(BUZZER_PIN); } } //开学快乐! )
[修改于 2个月22天前 - 2024/08/31 17:50:18]
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |
200字以内,仅用于支线交流,主线讨论请采用回复功能。