SoftwareSerial.h missing on ArduinoDUE for bluetooth

Hi i have arduino due and HC-05. I have installed ArduinoBlue ArduinoBlue which requires SoftwareSerial.h and great mobile App

How do I fix this?

Adding SoftwareSerial.h manually makes million of errors. My Arduino mega practically died with Timeout error when uploading code so I only have due

#include <SoftwareSerial.h>
#include <ArduinoBlue.h>

int PUL = 48; //define Pulse pin
int DIR = 50; //define Direction pin
int ENA = 52; //define Enable Pin


const int BLUETOOTH_TX = 8;
// Bluetooth RX -> Arduino D7
const int BLUETOOTH_RX = 7;

SoftwareSerial bluetooth(BLUETOOTH_TX, BLUETOOTH_RX);
ArduinoBlue phone(bluetooth); // pass reference of bluetooth object to ArduinoBlue constructor.


int speed = 10000;
int enabled = 1;
int dir = 0; 
int forLoop = 0;

void setup() {
  pinMode (PUL, OUTPUT);
  pinMode (DIR, OUTPUT);
  pinMode (ENA, OUTPUT);
  
  pinMode (PUL2, OUTPUT);
  pinMode (DIR2, OUTPUT);
  pinMode (ENA2, OUTPUT);

  digitalWrite(ENA, enabled);

 Serial.begin(9600);

  // Start bluetooth serial at 9600 bps.
  bluetooth.begin(9600);

  // delay just in case bluetooth module needs time to "get ready".
  delay(100);

  Serial.println("setup complete");
  
}

void loop() 
{
  int state = 99;

  state = phone.getButton();

    // Returns the text data sent from the phone.
    // After it returns the latest data, empty string "" is sent in subsequent.
    // calls until text data is sent again.
    String str = phone.getText();
  if(str.length() > 0 )
  {

    speed = str.toInt();
    Serial.println(speed);

  }
  
  Serial.println(state);

  if (state == 0) //play
  {
    enabled = 0;
    Serial.println("enabled 0");
  }
  else if (state == 1) //stop
  {
    enabled = 1;
    Serial.println("enabled 1");
  } 
  else if (state == 2) //dir
  {
    dir = 0;
    Serial.println("dir 0");
  }
  else if (state == 3) //dir 2
  {
    dir = 1;
    Serial.println("dir 1");
  }
  else
  {
   Serial.println("state 99");
   state = 99;
  }

  digitalWrite(ENA, enabled);
  
  if(enabled == 0 && speed >= 10)
  {
    forLoop = speed/10;
    for (int i = 0; i < forLoop ; i++) //UP 5000 steps
    {
      digitalWrite(DIR, dir);
      digitalWrite(ENA, enabled);
      digitalWrite(PUL, HIGH);
      delayMicroseconds(speed);
      digitalWrite(PUL, LOW);
      delayMicroseconds(speed);
    }
  }
}

The Due has 4 extra hardware serial ports available: Serial, Serial1, Serial2, Serial3. It's always better to use hardware serial than software serial. See if you can pass one of the hardware serial objects to the library and connect your device to the hardware serial pins. Then you will have no need of a sofware serial library for Due.

There are 4 hardware Serial, plus a fifth one, Serial4 with 3 lines of code to add. And yes that's a much better option than using a software serial.

However antodom has released a soft_uart library for the DUE:

ard_newbie:
plus a fifth one, Serial4 with 3 lines of code to add.

Would you mind providing some details about Serial4? I have never heard of this before. My understanding is the serial ports are:

  • SerialUSB: The CDC serial port only available via the Native USB Port.
  • Serial: Pins 0 and 1 and the Programming Port
  • Serial1: Pins 19 and 18
  • Serial2: Pins 17 and 16
  • Serial3: Pins 15 and 14

I searched the Arduino SAM core and didn't find any instances of Serial4.

An example sketch with Serial4:

/**********************************************************************/
/******   Hook jumpers between RX1 and A11, and TX1 and pin 52  *******/
/**********************************************************************/

// Use the Arduino core to set-up the unused USART2 on Serial4
RingBuffer rx_buffer5;
RingBuffer tx_buffer5;
USARTClass Serial4(USART2, USART2_IRQn, ID_USART2, &rx_buffer5, &tx_buffer5);
void USART2_Handler(void)   // Interrupt handler for USART2
{
  Serial4.IrqHandler();     // In turn calls on the Serial4 interrupt handler
}

char c = 0;
void setup() {
  PIO_Configure(PIOB, PIO_PERIPH_A, PIO_PB20A_TXD2 /* | PIO_PB21A_RXD2*/, PIO_DEFAULT);
  Serial.begin(250000);
  Serial1.begin(1000000);
  Serial4.begin(1000000);

  Serial4.print("Hello");
}


void loop() {
  String s;
  s = "";

  while (Serial1.available() > 0) {
    c = Serial1.read();
    s += c;
  }
  if (s.length() > 0) {
    Serial.println(s);
    Serial4.print(s);
  }
  delay(1000);
}

Thanks so much ard_newbie! That Due is really quite a capable board. I own one, but have never actually used one in a project yet.