一.功能概述
摄像头的画面可以实时的传输到,点灯科技APP的手机端,这样可以实时查看周围环境的状况,灯光不足,画面不清晰时可以打开灯光照明。手机端有左转、右转、前进、后退、停止的按钮。可以根据自己需要,来控制小车。手机APP端还设有模式切换的按钮,可以根据需要进行避障和手动模式的切换。
二、项目模块
小车套件,舵机、esp32-cam、稳压模块、电机驱动模块、超声波模块、开光按钮
三、代码演示
#define BLINKER_WIFI
#include <Blinker.h>
#include "ESP32_CAM_SERVER.h"#define LED 4
#define DriveLeft_A 13 //控制左轮转动方向
#define DriveLeft_B 15
#define DriveRight_A 14 //控制右轮转动方向
#define DriveRight_B 2
#define ServoPin 12 //舵机的引脚
#define Echo 3 //超声波echo
#define Trig 1 //超声波trigconst char* ssid = "nova7"; //wifi账号
const char* password = "66666666"; //wifi密码
char auth[] = "5e3ebc64737f";
int modeflag;
int Wave_len_R;
int Wave_len_L;
bool setup_camera = false;//摄像头默认不开启BlinkerButton Button1("GoForward"); //前进按键
BlinkerButton Button2("GoBack"); //后退按键
BlinkerButton Button3("Left"); //左转按键
BlinkerButton Button4("Right"); //右转按键
BlinkerButton Button5("Stop"); //停车按键
BlinkerButton Button6("led"); //led灯
BlinkerButton Button7("mode"); //模式切换按钮
BlinkerSlider Slider1("duoji"); //舵机滑块//****定义运动函数***********************************//
void Go_Forward( ) // 前进
{digitalWrite(DriveLeft_A, HIGH);digitalWrite(DriveRight_A, HIGH);digitalWrite(DriveLeft_B, LOW); digitalWrite(DriveRight_B, LOW);
}void Go_Back( ) //后退
{ digitalWrite(DriveLeft_A, LOW);digitalWrite(DriveRight_A, LOW); digitalWrite(DriveLeft_B, HIGH);digitalWrite(DriveRight_B, HIGH);
}
void Stop_Car( ) //停止
{digitalWrite(DriveLeft_A, LOW);digitalWrite(DriveLeft_B, LOW);digitalWrite(DriveRight_A, LOW);digitalWrite(DriveRight_B, LOW);
}void Turn_Left( )// 左转
{