0

I am using Arduino and NetBeans in my project. My final work is to switch from Arduino program to Java. I managed to install an Arduino-NetBeans plugin as described in Arduino - NetBeans Plugin detail

My Arduino program includes

Serial.begin(9600); /////// Serial.print();

I get an error saying that "Unable to resolve identifier Serial". How can I solve this?

3 Answers 3

2

this is what you have to add to your source file:

#include <Arduino.h>
// imports the Serial class to allow log output
extern HardwareSerial Serial;

then it will work.

Sign up to request clarification or add additional context in comments.

Comments

2

As answered by cgo you can add extern HardwareSerial Serial;

netbeans arduino serial

Or into your Project Settings, go to BUILD > C++ COMPILER > PREPROCESSOR DEFINITIONS and add: __AVR_ATmega328P__ (if you are working with Arduino UNO)

netbeans arduino preprocessor

Comments

0

The message "unable to resolve identifier Serial" means that the compiler is searching for the variable Serial, but cannot find its declaration. You should check if you include all header files properly. I don't know the NetBeans plugin, but I guess the Serial-structure/class is initialised there.

If that is not helping, you should check the compiler otions and set them to default, as described on the project-site.

Comments

Your Answer

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.