能够蓝牙点火的采集卡[附接线图和代码]
bbbbmmdddd2024/08/28原创 极客DIY电子技术 IP:天津
中文摘要
能够蓝牙点火的采集卡
还能放音乐_熙熙攘攘我们的城市 : )
关键词
推力采集卡

代码放最后 AWA 代码有点长,所以放在了最后 : )

材料表(主要材料)

序号名称
规格
1ESP32开发板看着买
2HX711模块推荐买紫色或红色款的
3继电器3V/5v  5/4引脚 建议不要买常开型
4蜂鸣器无源
5TF卡模块

带电平转换芯片

本采集卡使用ESP32 作为主控 arduino进行开发

明天开学力,电脑要没收了 : (

祝大家开学快乐 : )

拆解前

a26451dfe50ccfc30b3596976233c2f1.jpg

拆解后 (用TIM编辑的图片不知道为什么,字变小了 sticker )

_$T8SXA_]TZ]OWG$[0}O1EM.png

由于我没有3v的继电器,所以弄了个升压板,如果购买的是3v/5v继电器就可以不用了 : )

由于继电器有4角5脚的,常闭,常开的,所以在接继电器的时,要看好下图的接线图,图中举出了3种继电器接线方法,接线时 请认真看好,否则可能出现上电就点火的危险情况!!!认真看好!!!

接线图(手画的 不太好 见谅)

46c69ff241ced298558589d2885f26a1.jpg

蓝牙命令(使用蓝牙串口调试助手)  以下命令可在程序中自定义 : )

在执行 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个月0天前 - 2024/08/31 17:50:18]

+0.5  科创币    反氕    2024/08/28 投资入股【喜】
来自:综合交流区 / 极客DIY电子信息 / 电子技术
1
5
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
暴龙兽想想
22天21时前 IP:广西
938165

感谢感谢。

引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

bbbbmmdddd
进士 机友 笔友
文章
1
回复
0
学术分
0
2023/12/31注册,3天7时前活动
暂无简介
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:天津
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}