Bluetooth command terminator code problem

The code you posted does not compile successfully with this error

operation on 'monedas' may be undefined

//monedas = monedas ++;
monedas++; // or alternatively monedas = monedas +1;

It would be best to revise your bluetooth serial input to use the methods used in the excellent tutorial Serial Input Basics.

I'm not exactly clear what you intend with your program, but I have revised it so that it appears to function as you intended with both "manda*" and '#' for input.

I have tested with Kai Morich's Serial Bluetooth Terminal. I highly recommend it.

I have changed the pin mode for pinmonedas to INPUT_PULLUP and look for a LOW reading. Otherwise you will need an external pulldown resistor to keep the pin from floating.

I have used a newMessage flag to control the responses to the input.

Both envia and monedas should be bytes as you are only using one eepeom location. However, with the ep32 Preferences.h is preferred over eeprom.h

#include <BluetoothSerial.h>
#include <EEPROM.h>
#define EEPROM_SIZE 12

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

String comando; // variable que recibe string de comandos
//int sw = 0; //Variable verdadero falso al recibir delimitador de comando
int pinmonedas = 5;
byte monedas;
byte envia;
boolean newMessage = false;

BluetoothSerial SerialBT;

void setup() {

  Serial.begin(9600);
  Serial.println();

  SerialBT.begin("ESP32test");
  EEPROM.begin(EEPROM_SIZE);

  Serial.println("Ya puedes conectar");

  pinMode(pinmonedas,INPUT_PULLUP);

  monedas = EEPROM.read(1);
  //EEPROM.read(0, monedas);
  Serial.print("monedas:");
  Serial.println(monedas);
  delay(500);
}

void loop() {

  while (SerialBT.available()) {
    char recibe = (char)SerialBT.read();
    comando += recibe;
    newMessage = true;
  }

  //process new message
  if (newMessage) {
    newMessage = false;
    if (comando == "manda*")  {
      Serial.println("comando");
    }
    else if (comando == "#") {
      Serial.print("Cantidad:");
      Serial.println(envia);
    }
    else {
      Serial.println("error");
    }
    comando = ""; //clear string for next message   
  }

  //if (digitalRead (pinmonedas) == HIGH)
  if (digitalRead (pinmonedas) == LOW) //use INPUT_PULLUP on button
  {
    //monedas = monedas ++;
    monedas++; //monedas = monedas +1;
    Serial.print("Monedas: ");
    Serial.println(monedas);
    EEPROM.write(1, monedas);
    EEPROM.commit();
    delay(500);
  }

  envia = monedas;
  SerialBT.println(monedas);
  delay(2000);
}