I'm trying to convert a class header file from another c++ project to arduino, which in my mind involves replacing cout with Serial.println.

When I try to recomplile with all of these changes, I get this error from the compiler:

error: 'Serial' was not declared in this scope

Can someone explain this to me?

1 Answer 1


You have to #include <Arduino.h>, or compile with the -include Arduino.h flag. The Arduino IDE normally does that for you, but you have to do it yourself if you are working outside the IDE.

There are a couple of Arduino Makefiles floating around the Web which, just like the IDE, take care of this for you.

  • I'm actually using the Arduino IDE. :\ May 16, 2015 at 1:59
  • Are you compiling a .ino or a .cpp? If it's a .cpp, the IDE is probably not adding the #include. If it's a .ino, it may just have messed your code. In the IDE options, you can ask to see all the compile-time messages. This will show the g++ command-line and tell you if it's compiling your original source or a modified version. You will also see the paths of the temporary cpp files it's creating, check their contents, and see if it has broken something. May 16, 2015 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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