0

I recently switched computers and installed Arduino IDE, Added SAMD21 to the boards manager and installed drivers.

My sketch previously ran on my laptop with no problems. Now when I try to compile for the SAMD21 Mini, I get a 'Serial1' was not declared in this scope error.

If I try to compile it for Mega, there are no problems.

I have tried sample code with Serial1 for SAMD21 and it compiled and uploaded with no problems.

asked Jan 19, 2021 at 20:28
3
  • The samd21g serial options are more configurable than for an AVR. Much of this is left to the variant definition. So which board do you have selected? Commented Jan 19, 2021 at 20:48
  • I selected "SparkFun SAMD21 Mini Breakout". I got it working see below :) Commented Jan 19, 2021 at 20:51
  • 2
    Given that you're now liable to be the only person to answer the question, you may want to just edit the question and answer to make a good read for whomever comes across it in the future. E.g. the question doesn't mention that you're not working in an .ino file. Commented Jan 19, 2021 at 20:53

1 Answer 1

1

Ahhhh, I figured it out. I had to add #include "Arduino.h" to the .cpp file.

timemage
5,6391 gold badge14 silver badges25 bronze badges
answered Jan 19, 2021 at 20:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.