Program don´t work with BLE

The program is a Lightchaser which is controlled via shift registers and interrupts. As you can see in my code, the interrupt and millis are used. I tryed it with a Nano and ESP controller. The code works well without the funcion of BLEcommands.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX

#include "ShiftRegisterPWM.h"

ShiftRegisterPWM sr(1, 16);
int c;

float brightness = 90;
float rate = 1000.0;
float sinus = 12.0;

void setup()

  pinMode(2, OUTPUT); // sr data pin
  pinMode(3, OUTPUT); // sr clock pin
  pinMode(4, OUTPUT); // sr latch pin

void loop()
 c =;
if(c==49){   //delete this and the program works as it should! ...but without control
if (c == 48){
} }

void welle(){
for (uint8_t i = 0; i < 8; i++) {
uint8_t val = (uint8_t)(((float)sin(millis() / rate - i / sinus * 2.0 * PI) + 1) * brightness);
sr.set(i, val);
} }

void stopp(){
    for (uint8_t i = 0; i < 8; i++) {
    uint8_t val = 0;
    sr.set(i, val);

With this code, the movement of the light wave is frozen. In the terminal I got 8 numbers for the millis () and the program stops.

if the command “if (c == 49)” is deleted, then the wave moves as it should (without Bluetooth control). The millis continue to run as well in the terminal.

Would be great if someone could help me out here. Thanx!

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX

Incredibly stupid. If the hardware serial pins are available, use the Serial instance to deal with them. If they are not available, because you are already using Serial, then you can’t possibly also do software serial on them.

Thank you! Yes I tought that… i also tryed to make a swich on a digital in port but this also didn´t work very well (the light was flickering).
hm …so are there any other solutions? i could also make a relay switch to turn on the controller with an other one… but then i don´t have any controll over my program…

so are there any other solutions?

SoftwareSerial on other pins.
A different Arduino with multiple hardware serial ports.