user82238: I'm trying to execute programs on my arduino based on values received via bluetooth. Although I've experimented a lot, I'm unable to get the code to  work.
I have build a simple android app with three buttons that sends either value "11", "21" or "31" to the arduino over bluetooth, which should trigger the code to operate a DIY wake-up-light (ESP32 + NeoPixels). Can anyone tell me what I'm doing wrong? Thanks in advance!
#include "BluetoothSerial.h" 
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

// init Class:
BluetoothSerial ESP_BT; 

#define LED_PIN    5
#define LED_COUNT 7

Adafruit_NeoPixel matrix = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  matrix.begin();
  matrix.show(); // Initialize all pixels to 'off'

  Serial.begin(19200);
  ESP_BT.begin("Wake_Up_Light"); //Name of Bluetooth interface
}

int led_pin_1 = 5;
int incoming;


void loop() {

// ------------ call wakeup program or gotosleep program ----------------
  if (ESP_BT.available()) 
  {
    incoming = ESP_BT.read(); //Read what we receive 


    int rnumber = incoming;
    
    switch (rnumber) {
      case 1:  
        Serial.print("11"); //----- Activate wake-up light after 6 hours -----
          6hours();
          wakeup();
          ledsoff();
        break;
      
      case 2:  
        Serial.print("21"); //----- Activate go-to-sleep mode -----
          gotosleep();
        break;
      
      case 3:  
        Serial.print("31"); //----- Activate powernap mode -----
          gotosleep();
          wakeupdelay();
          wakeup(); 
          ledsoff();
        break;
      }
  }
}

void wakeup() {

    uint16_t i, j;

  for (j = 1; j < 10; j++) {
    for (i = 0; i <LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(18000); //-------- 180.000ms (3 minutes) / 10 steps = 18.000 ---------
  }
}

void gotosleep() {

    uint16_t i, j;
  for (j = 10; j > 0; j--) {
    for (i = 0; i <LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(16363); // ---- 180000ms (3 minutes) / 11 steps = 16363 --------
  }
  matrix.setBrightness(0);
  delay(40000); // ---- 40 seconds delay
  }

void wakeupdelay() {
  delay(1200000);
}

void ledsoff() {
    matrix.setBrightness(0);
}

void 6hours() {
  delay(21600000)
}


user82238: Thanks for the replies. I've taken another aproach and was able to get the code to work. I'll post it here. Not yet 100% finished, but mostly doing what I wanted.
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "BluetoothSerial.h"
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define LED_PIN    5
#define LED_COUNT 7

Adafruit_NeoPixel matrix = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

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

BluetoothSerial ESP_BT;
void printDeviceAddress() {

const uint8_t* point = esp_bt_dev_get_address();

for (int i = 0; i < 6; i++) {
   char str[3];
   sprintf(str, "%02X", (int)point[i]);
   Serial.print(str);
   if (i < 5){
   Serial.print(":");}
}
Serial.println();
}

void setup()
{
Recvd = "";

Serial.begin(19200);

  ESP_BT.begin("Wake_Up_Light");
  Serial.println("Address:");
  printDeviceAddress();

}

int led_pin_1 = 5;
int incoming;

void loop()
{
matrix.setBrightness(0);
matrix.show();
    if (ESP_BT.available()) {
      Recvd = (ESP_BT.read());
      Serial.println("Received value:");
      Serial.println(Recvd);
      if (Recvd == "11") {
        Serial.println("Running wake-up>6hr mode");
        sixhours();
        wakeup();
        ledsoff();

      }
      if (Recvd == "21") {
        Serial.println("Running go-to-sleep mode");
        gotosleep();

      }
      if (Recvd == "31") {
        Serial.println("Running powernap mode");
        gotosleep();
        wakeupdelay();
        wakeup(); 
        ledsoff();

      }

    }

}

void wakeup() {

    uint16_t i, j;

  for (j = 1; j < 10; j++) {
    for (i = 0; i <LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(18000); //-------- 180.000ms (3 minutes) / 10 steps = 18.000 ---------
  }
}

void gotosleep() {

    uint16_t i, j;
  for (j = 10; j > 0; j--) {
    for (i = 0; i <LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(16363); // ---- 180000ms (3 minutes) / 11 steps = 16363 --------
  }
  matrix.setBrightness(0);
  delay(40000); // ---- 40 seconds delay
  }

void wakeupdelay() {
  delay(1200000); // (20 minutes)
}

void ledsoff() {
    matrix.setBrightness(0);
}

void sixhours() {
  delay(21600000); // (6 hours)
}


82238: <p>I'm trying to execute programs on my arduino based on values received via bluetooth. Although I've experimented a lot, I'm unable to get the code to  work.</p>
<p>I have build a simple android app with three buttons that sends either value &quot;11&quot;, &quot;21&quot; or &quot;31&quot; to the arduino over bluetooth, which should trigger the code to operate a DIY wake-up-light (ESP32 + NeoPixels). Can anyone tell me what I'm doing wrong? Thanks in advance!</p>
<pre><code>#include &quot;BluetoothSerial.h&quot; 
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_NeoMatrix.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;

// init Class:
BluetoothSerial ESP_BT; 

#define LED_PIN    5
#define LED_COUNT 7

Adafruit_NeoPixel matrix = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  matrix.begin();
  matrix.show(); // Initialize all pixels to 'off'

  Serial.begin(19200);
  ESP_BT.begin(&quot;Wake_Up_Light&quot;); //Name of Bluetooth interface
}

int led_pin_1 = 5;
int incoming;


void loop() {

// ------------ call wakeup program or gotosleep program ----------------
  if (ESP_BT.available()) 
  {
    incoming = ESP_BT.read(); //Read what we receive 


    int rnumber = incoming;
    
    switch (rnumber) {
      case 1:  
        Serial.print(&quot;11&quot;); //----- Activate wake-up light after 6 hours -----
          6hours();
          wakeup();
          ledsoff();
        break;
      
      case 2:  
        Serial.print(&quot;21&quot;); //----- Activate go-to-sleep mode -----
          gotosleep();
        break;
      
      case 3:  
        Serial.print(&quot;31&quot;); //----- Activate powernap mode -----
          gotosleep();
          wakeupdelay();
          wakeup(); 
          ledsoff();
        break;
      }
  }
}

void wakeup() {

    uint16_t i, j;

  for (j = 1; j &lt; 10; j++) {
    for (i = 0; i &lt;LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(18000); //-------- 180.000ms (3 minutes) / 10 steps = 18.000 ---------
  }
}

void gotosleep() {

    uint16_t i, j;
  for (j = 10; j &gt; 0; j--) {
    for (i = 0; i &lt;LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(16363); // ---- 180000ms (3 minutes) / 11 steps = 16363 --------
  }
  matrix.setBrightness(0);
  delay(40000); // ---- 40 seconds delay
  }

void wakeupdelay() {
  delay(1200000);
}

void ledsoff() {
    matrix.setBrightness(0);
}

void 6hours() {
  delay(21600000)
}
</code></pre>
 82238: <p>Thanks for the replies. I've taken another aproach and was able to get the code to work. I'll post it here. Not yet 100% finished, but mostly doing what I wanted.</p>
<pre><code>#include &quot;esp_bt_main.h&quot;
#include &quot;esp_bt_device.h&quot;
#include &quot;BluetoothSerial.h&quot;
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_NeoMatrix.h&gt;
#include &lt;Adafruit_NeoPixel.h&gt;

#define LED_PIN    5
#define LED_COUNT 7

Adafruit_NeoPixel matrix = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

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

BluetoothSerial ESP_BT;
void printDeviceAddress() {

const uint8_t* point = esp_bt_dev_get_address();

for (int i = 0; i &lt; 6; i++) {
   char str[3];
   sprintf(str, &quot;%02X&quot;, (int)point[i]);
   Serial.print(str);
   if (i &lt; 5){
   Serial.print(&quot;:&quot;);}
}
Serial.println();
}

void setup()
{
Recvd = &quot;&quot;;

Serial.begin(19200);

  ESP_BT.begin(&quot;Wake_Up_Light&quot;);
  Serial.println(&quot;Address:&quot;);
  printDeviceAddress();

}

int led_pin_1 = 5;
int incoming;

void loop()
{
matrix.setBrightness(0);
matrix.show();
    if (ESP_BT.available()) {
      Recvd = (ESP_BT.read());
      Serial.println(&quot;Received value:&quot;);
      Serial.println(Recvd);
      if (Recvd == &quot;11&quot;) {
        Serial.println(&quot;Running wake-up&gt;6hr mode&quot;);
        sixhours();
        wakeup();
        ledsoff();

      }
      if (Recvd == &quot;21&quot;) {
        Serial.println(&quot;Running go-to-sleep mode&quot;);
        gotosleep();

      }
      if (Recvd == &quot;31&quot;) {
        Serial.println(&quot;Running powernap mode&quot;);
        gotosleep();
        wakeupdelay();
        wakeup(); 
        ledsoff();

      }

    }

}

void wakeup() {

    uint16_t i, j;

  for (j = 1; j &lt; 10; j++) {
    for (i = 0; i &lt;LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(18000); //-------- 180.000ms (3 minutes) / 10 steps = 18.000 ---------
  }
}

void gotosleep() {

    uint16_t i, j;
  for (j = 10; j &gt; 0; j--) {
    for (i = 0; i &lt;LED_COUNT; i++) {
      matrix.setBrightness(255);
      matrix.setPixelColor(i, 3, j, j);
    }
    matrix.show();
    delay(16363); // ---- 180000ms (3 minutes) / 11 steps = 16363 --------
  }
  matrix.setBrightness(0);
  delay(40000); // ---- 40 seconds delay
  }

void wakeupdelay() {
  delay(1200000); // (20 minutes)
}

void ledsoff() {
    matrix.setBrightness(0);
}

void sixhours() {
  delay(21600000); // (6 hours)
}
</code></pre>
