I have NewSoftSerial.h and NewSoftSerial.cpp in the same folder as my sketch.

The sketch is thus.

#include <NewSoftSerial.h>

int incomingByte = 0;   // for incoming serial data
NewSoftSerial bluetooth(2, 3);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  //enter command mode

void loop() {
  // send data only when you receive data:
  if (Serial.available() > 0) {
    //read the incoming byte:
    incomingByte = Serial.read();

    //say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, BYTE);

What am I doing wrong that I get these errors?

trainremotesketch.cpp:1:27: error: NewSoftSerial.h: No such file or directory trainremotesketch:3: error: 'NewSoftSerial' does not name a type


2 Answers 2


The short answer is that library files go in the libraries folder in the Arduino root folder. A library should be in a sub-folder named for the class, and should contain a c++ implementation and header file.


A longer answer is that if you want to include a header file which isn't in the library path, you use double quotes, instead of angle brackets:

#include "NewSoftSerial.h"
  • 6
    \$\begingroup\$ This answer is actually shorter \$\endgroup\$ Jul 8, 2014 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.