Go Down

Topic: NewSoftSerial 10C Compile errors (Read 1 time) previous topic - next topic


I am trying to comple a project using the NewSoftSerial v10c library. I get the following errors:

In file included from WT12A_newsoft.cpp:1:
C:\_projects\Arduino\arduino-1.0-rc2\libraries\NewSoftSerial/NewSoftSerial.h:86: error: ISO C++ forbids declaration of 'write' with no type
C:\_projects\Arduino\arduino-1.0-rc2\libraries\NewSoftSerial/NewSoftSerial.h:86: error: 'int NewSoftSerial::write(uint8_t)' cannot be overloaded
C:\_projects\Arduino\arduino-1.0-rc2\libraries\NewSoftSerial/NewSoftSerial.h:86: error: with 'virtual size_t NewSoftSerial::write(uint8_t)'

Here is the code. Works fine with SoftwareSerial

Code: [Select]

#include <NewSoftSerial.h>

// Arduino Shields WT12A Bluetooth Shield demo code
// www.arduino.com.au
// v1.00 13-Oct-2011 - first release
// tested on Arduino Uno

//#include <SoftwareSerial.h>

#define rxPin 2 // define receive pin for serial port 2
#define txPin 3 // define transmit pin for serial port 2

//SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin); // define serial port 2
NewSoftSerial mySerial(rxPin,txPin);

byte serialin = 0; // for incoming serial data

void setup()
  pinMode(rxPin, INPUT); // rxpin iput fopr serial port 2
  pinMode(txPin, OUTPUT);

  mySerial.begin(2400); // talk to WT12A at 2400 baud
  Serial.begin(9600);  // std serial port set to 9600 baud

  mySerial.print("SET\r\n"); // send out SET to read all settings

void loop()
  while (Serial.available()) { // check if data has been sent from the computer:
    serialin = Serial.read(); // read serial byte
    mySerial.write(serialin); // and send to WT12A bluetooth module
    serialin = mySerial.read(); // if WT12A data, read and show
    if ((serialin<0x7f) && ( serialin>0x09)) {
    serialin = mySerial.read(); // read WT12A serial data
    if ((serialin<0x7f) && ( serialin>0x09)) {
      Serial.write(serialin);    // display if valid ascii


Coding Badly

Which version of the Arduino IDE are you using?


No need to use NewSoftSerial in Arduino 1.0 -- it's built in!  (... under the name SoftwareSerial).


We are using 1.0 RC2. Does that mean SoftwareSerial the same as NewSoftSerial v10C?

The only reason to move to NewSoftSerial is that SoftwareSerial only seems to work reliably at 2400 baud, less reliably at 4800 and not at all well at 9600.

Go Up