I am getting this in my serial monitor whe i connect my esp32 with pc and can't upload or run any code.
Plz reply quickly if you can solve this..
CAR_WITH_BLUETOOTH.ino
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
#define M1_in1 32
#define M1_in2 25
#define M1_en 33
#define M2_in1 26
#define M2_in2 12
#define M2_en 14
#define M4_in2 23
#define M4_in1 21
#define M4_en 22
#define M3_in2 18
#define M3_in1 4
#define M3_en 5
#define volt 34
#define led 2
float voltage;
int pwm = 255;
byte power = 0;
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
delay(100);
SerialBT.begin("ESP32_CAR"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
ledcSetup(0, 5000, 8);
ledcAttachPin(M1_en, 0);
ledcSetup(1, 5000, 8);
ledcAttachPin(M2_en, 1);
ledcSetup(2, 5000, 8);
ledcAttachPin(M3_en, 2);
ledcSetup(3, 5000, 8);
ledcAttachPin(M4_en, 3);
pinMode(M1_in1, OUTPUT);
pinMode(M1_in2, OUTPUT);
pinMode(M2_in1, OUTPUT);
pinMode(M2_in2, OUTPUT);
pinMode(M3_in1, OUTPUT);
pinMode(M3_in2, OUTPUT);
pinMode(M4_in1, OUTPUT);
pinMode(M4_in2, OUTPUT);
pinMode(volt, INPUT);
pinMode(2, OUTPUT);
}
void loop()
{
voltage = analogRead(volt) * 11.4 / 2960;
Serial.print("voltage = ");
Serial.println(voltage);
// if(voltage=11)
// {
// SerialBT.write("BATTERY LOW");
// power=0;
// }
// if(power=1){
if (SerialBT.available()) {
int command = SerialBT.read();
if (command == 'w') {
FORWARD();
} else if (command == 's') {
BACKWARD();
} else if (command == 'd') {
RIGHT();
} else if (command == 'a') {
LEFT();
} else if (command == 'x') {
BREAK();
} else if (command == ' ') {
STOP();
}
}
}
void FORWARD() {
digitalWrite(2, HIGH);
digitalWrite(M1_in1, 0);
digitalWrite(M1_in2, 1);
ledcWrite(0, pwm);
digitalWrite(M2_in1, 0);
digitalWrite(M2_in2, 1);
ledcWrite(1, pwm);
digitalWrite(M3_in1, 0);
digitalWrite(M3_in2, 1);
ledcWrite(2, pwm);
digitalWrite(M4_in1, 0);
digitalWrite(M4_in2, 1);
ledcWrite(3, pwm);
Serial.println("FORWARD");
}
void RIGHT() {
digitalWrite(2, HIGH);
digitalWrite(M1_in1, 0);
digitalWrite(M1_in2, 1);
digitalWrite(M2_in1, 0);
digitalWrite(M2_in2, 1);
digitalWrite(M3_in1, 1);
digitalWrite(M3_in2, 0);
digitalWrite(M4_in1, 1);
digitalWrite(M4_in2, 0);
ledcWrite(0, pwm);
ledcWrite(1, pwm);
ledcWrite(2, pwm);
ledcWrite(3, pwm);
Serial.println("LEFT");
}
void BACKWARD() {
digitalWrite(2, HIGH);
digitalWrite(M1_in1, 1);
digitalWrite(M1_in2, 0);
digitalWrite(M2_in1, 1);
digitalWrite(M2_in2, 0);
digitalWrite(M3_in1, 1);
digitalWrite(M3_in2, 0);
digitalWrite(M4_in1, 1);
digitalWrite(M4_in2, 0);
ledcWrite(0, pwm);
ledcWrite(1, pwm);
ledcWrite(2, pwm);
ledcWrite(3, pwm);
Serial.println("BACKWARD");
}
void LEFT() {
digitalWrite(2, HIGH);
digitalWrite(M1_in1, 1);
digitalWrite(M1_in2, 0);
digitalWrite(M2_in1, 1);
digitalWrite(M2_in2, 0);
digitalWrite(M3_in1, 0);
digitalWrite(M3_in2, 1);
digitalWrite(M4_in1, 0);
digitalWrite(M4_in2, 1);
ledcWrite(0, pwm);
ledcWrite(1, pwm);
ledcWrite(2, pwm);
ledcWrite(3, pwm);
Serial.println("RIGHT");
}
void BREAK() {
digitalWrite(2, HIGH);
digitalWrite(M1_in1, HIGH);
digitalWrite(M1_in2, HIGH);
digitalWrite(M2_in1, HIGH);
digitalWrite(M2_in2, HIGH);
digitalWrite(M3_in1, HIGH);
digitalWrite(M3_in2, HIGH);
digitalWrite(M4_in1, HIGH);
digitalWrite(M4_in2, HIGH);
ledcWrite(0, 255);
ledcWrite(1, 255);
ledcWrite(2, 255);
ledcWrite(3, 255);
Serial.println("BREAK");
}
void STOP() {
digitalWrite(2, LOW);
digitalWrite(M1_in1, LOW);
digitalWrite(M1_in2, LOW);
digitalWrite(M2_in1, LOW);
digitalWrite(M2_in2, LOW);
digitalWrite(M3_in1, LOW);
digitalWrite(M3_in2, LOW);
digitalWrite(M4_in1, LOW);
digitalWrite(M4_in2, LOW);
ledcWrite(0, 0);
ledcWrite(1, 0);
ledcWrite(2, 0);
ledcWrite(3, 0);
}
CAR_WITH_BLUETOOTH.ino (4.1 KB)
CAR_WITH_BLUETOOTH.ino (4.1 KB)