arduino mega 2560 with sweep scanse

i tried running my code but it either cant shows the reading of my sweep scanse or it shows the reading of the sweep scanse but i am unable to control it using my bluetooth module HC06. i’m trying to programme the irobot create to do the what the bluetooth commends and also able to make it run autonomous while avoiding obstacle using the sweep scanse

the attachment below is my code

#include<SoftwareSerial.h>
#define rxPin 10
#define txPin 11
#include "roombaDefines.h"
#include <Sweep.h>


unsigned long previousMillisBT1=0;
unsigned long previousMillisSweep=0;
const unsigned long intervalBT1 = 500;
const unsigned long intervalSweep = 1000;

SoftwareSerial softSerial = SoftwareSerial(rxPin,txPin);

SoftwareSerial BT1(12, 13);


Sweep device(Serial1);
uint8_t scanCount = 0;
uint16_t sampleCount = 0;
bool syncValues[500];   
uint16_t distances[500];
uint16_t angle[500];

void setup() {
 delay(1000);

 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);

 BT1.begin(9600);
 BT1.println("Hello from Arduino");

 softSerial.begin(57600);

 Serial.begin(57600);

 softSerial.write(128);
 softSerial.write(131);


Serial1.begin(115200);
Serial.println("Display numbers:");

}

char c;

void loop() {
  unsigned long currentMillis = millis();
  if ((unsigned long)(currentMillis - previousMillisBT1) >= intervalBT1) {  
  BT1.listen();
  if(BT1.available() > 0){
    c = BT1.read();
    movement(c);
    }
  previousMillisBT1 = currentMillis;
  }

  if ((unsigned long)(currentMillis - previousMillisSweep) >= intervalSweep) {
  device.setMotorSpeed(MOTOR_SPEED_CODE_5_HZ); 
  device.startScanning(); 
  printCollectedData();
     previousMillisSweep = currentMillis;
  }


  }

i even tried using millis() to divide the loop into 2 activities running together

void gatherSensorReading()
{
  // attempt to get the next scan packet
  // Note: getReading() will write values into the "reading" variable
  bool success = false;
  ScanPacket reading = device.getReading(success);
  if (success)
  {

    // store the info for this sample
    syncValues[sampleCount] = reading.isSync();
    distances[sampleCount] = reading.getDistanceCentimeters();
    angle[sampleCount] = reading.getAngleDegrees();

    // increment sample count
    sampleCount++;
    //Serial.println(sampleCount);
  }
}

void printCollectedData()
{

  gatherSensorReading();
  int indexOfFirstSyncReading = 0;
  // don't print the trailing readings from the first partial scan
  while (!syncValues[indexOfFirstSyncReading])
  {
    indexOfFirstSyncReading++;
  }
  // print the readings for all the complete scans
  for (int i = indexOfFirstSyncReading; i < sampleCount; i++)
  {
    Serial.println(String(distances[i]) + "," + String(angle[i], 3));
    delay(1000);
  }
}

this is the code for the sweep

void movement(char c)
{
  Serial.print(c);
  switch(c)
  {
    case'w':
    driveWheels(200,200);
    state = c;
    BT1.println(" Moving forward ");
      
    break;

    case'd':
    driveWheels(-100,100);
    BT1.println(" Turning right ");
    
    break;

    case'a':
    driveWheels(100,-100);
    BT1.println(" Turning left ");
    
    break;

    case's':
    driveWheels(-200,-200);
    state = c;
    BT1.println(" Moving backward ");
     
    break;

    case'b':
    driveStop();
    BT1.println(" Stop ");
     
    break;

    case'p':
   
  BT1.println("Autonomous");
    while(distances[sampleCount]<100 && angle[sampleCount]> 45 && angle[sampleCount]< 135){
      turnCW(20,15);
    }
    
    driveWheels(50,50);
    state = c;  
    

  }
}

this is the code for the movement

SoftwareSerial softSerial = SoftwareSerial(rxPin,txPin);

SoftwareSerial BT1(12, 13);

You have a Mega which has 4 hardware serial interfaces. Using SoftwareSerial on a Mega is not very clever and it's quite (sorry to say) stupid to use two instances of this horrible library.

softSerial.begin(57600);

Using SoftwareSerial above 19600 baud very seldom results in success, only if the counterpart is extremely timing tolerant. And if you get a communication all other task on the Arduino will be blocked because the library is blocking the hardware during very long time periods.

You forgot the links to your hardware and you forgot the wiring diagram of your setup!

haha i'm sorry i did such stupid mistakes. It's because this is my first time using arduino. i dont know what you mean by the links to my hardware, but i guess you meant the component that i used for this project that i'm doing?

i uses HC06 which is the bluetooth module
http://wiki.sunfounder.cc/index.php?title=Bluetooth_Transceiver_Module_HC-06

a arduino mega 2560

a sweep scanse
https://www.robotshop.com/eu/en/sweep-v1-360-laser-scanner.html

a irobot create
https://wiki.nps.edu/display/~thchung/ROS+--+iRobot+Create

sorry but i cant get you a wiring diagram of my project right now

sorry but i cant get you a wiring diagram of my project right now

Then sorry but the help you can expect to receive will be very limited.

Without knowing what hardware you have and how it is wired up it is impossible to tell if the code is correct.

this is my wiring diagram i dont know if you can see it properly or not

This is not exactly a schematic, more of a physical layout diagram.

I can not reconcile the Roomba connections with the iRobot create.
The Roomba needs a USB connector or a 25 Way DIN connector. Nether of which match your diagram. In your diagram you seem to have connected some SPI signals to the Roomba and you seem to be wanting it to run off 5V from the Arduino.

The unidentified blue thing at the bottom right seems to want 3V3 signals to it and yet you are connection 5V signals to it.

the blue thing at the bottom is the HC06 bluetooth and i’ve checked the bluetooth part of the system works just fine with it running at 5V

The bluetooth device still connects to the SoftwareSerial pins. Fix that.

The post your complete code, define what you expect from it and what you get. Otherwise we don't know how to help you.