esp32触发相机,测试成功上升沿触发
串口发送命令 up 20000 1 20000 触发
#include <Arduino.h>
const int outputPin = 12; // 输出引脚
String inputCommand = ""; // 串口输入缓冲区
// 解析命令参数,例如 "up 10 5" 解析为 delayMicrosecondsTime=10, repeatCount=5
// 解析命令参数,例如 "up 10 5" 解析为 delayMicrosecondsTime=10, repeatCount=5
bool parseParameters(String command, int &delayMicrosecondsTime, int &repeatCount) {
int firstSpace = command.indexOf(' '); // 查找第一个空格位置
if (firstSpace < 0) return false; // 没有参数
int secondSpace = command.indexOf(' ', firstSpace + 1); // 查找第二个空格位置
if (secondSpace < 0) return false; // 参数不完整
// 提取参数并转换为整数
String delayMicrosecondsStr = command.substring(firstSpace + 1, secondSpace);
String repeatStr = command.substring(secondSpace + 1);
delayMicrosecondsTime = delayMicrosecondsStr.toInt();
repeatCount = repeatStr.toInt();
// 检查参数是否合法
return delayMicrosecondsTime > 0 && repeatCount

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



