#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
BluetoothSerial BT;
void adelante(){
////MOTOR IZQUIERDO///
digitalWrite(22, HIGH);
digitalWrite(21, LOW);
analogWrite(23,255);
////MOTOR DERECHO///
digitalWrite(18, HIGH);
digitalWrite(19, LOW);
analogWrite(5,255);
}
void retroceder(){
////MOTOR IZQUIERDO///
digitalWrite(22,LOW);
digitalWrite(21,HIGH);
analogWrite(23,255);
////MOTOR DERECHO///
digitalWrite(18,LOW);
digitalWrite(19,HIGH);
analogWrite(5,255);
}
void derecha(){
////MOTOR IZQUIERDO///
digitalWrite(22,HIGH);
digitalWrite(21,LOW);
analogWrite(23,255);
////MOTOR DERECHO///
digitalWrite(18,LOW);
digitalWrite(19,HIGH);
analogWrite(5,255);
}
void izquierda(){
////MOTOR IZQUIERDO///
digitalWrite(22,LOW);
digitalWrite(21,HIGH);
analogWrite(23,255);
////MOTOR DERECHO///
digitalWrite(18,HIGH);
digitalWrite(19,LOW);
analogWrite(5,255);
}
void setup() {
BT.begin("ESP32test");
Serial.begin(9600);
//// PINES DEL MOTOR IZQUIERDO///
pinMode(22, OUTPUT);
pinMode(21, OUTPUT);
pinMode(23, OUTPUT);
//// PINES DEL MOTOR DERECHO/////
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
if(BT.available()){
char mensaje = BT.read();
if(mensaje == 'F')
{
adelante();
}
if(mensaje == 'B')
{
retroceder();
}
if(mensaje == 'R')
{
derecha();
}
if(mensaje == 'L')
{
izquierda();
}
}
}