Running an Arduino program in NetBeans 7.3 - arduino

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?

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.

As answered by cgo you can add extern HardwareSerial Serial;
Or into your Project Settings, go to BUILD > C++ COMPILER > PREPROCESSOR DEFINITIONS and add: __AVR_ATmega328P__ (if you are working with Arduino UNO)

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.

Related

How to compile and flash attiny88 with arduino-cli?

I can't understand, what device-name I should use for attiny88? For example, string for my old nano was arduino:avr:nano:cpu=atmega328old
I installed cores for attiny in arduino-cli, and test this board in ArduinoIDE and it works well, but I want to use arduino-cli.
(Sorry for my English)
Found the solution, this string named as FQBN. And I can get this FQBN for all my boards after exec command arduino-cli board listall

Ardino-Nano-BLE-Sense "Send Data With Sound" Chirp Project Issue

I am having some issues with the Send Data with Sound Project on Arduino. I have my Arduino nano BLE sense, ChirpSDK by Asio Ltd Version 3.4.0 installed, I put in the CHIRP_APP_KEY, CHIRP_APP_SECRET, CHIRP_APP_CONFIG from the chirp website, and I also have the Arduino nano BLE board selected when uploading the code. But for some reason I keep getting this error below:
ChirpColor:22:10: error: chirp_connect.h: No such file or directory
#include "chirp_connect.h"
^~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
chirp_connect.h: No such file or directory
Any help would be very much appreciated, thanks.
The SDK functions have been renamed in the latest release. So connect is replaced with sdk.
With the latest version, you need to
#include "chirp_sdk.h"
See the latest header file for the function declarations - https://github.com/chirp/chirp-arduino/blob/develop/src/chirp_sdk.h

Arduino-Makefile: do not understand how to correctly use USER_LIB_PATH

I'm using the Arduino-Makefile command-line-interface package on Linux, and recently I made an Arduino program that uses dht.h (a non-standard Arduino library) that I placed in directory /home/ramces/Sketchbook/libraries
my program includes the line:
#include <dht.h>
This is my makefile:
ARDUINO_DIR = /usr/share/arduino
ARDUINO_PORT = /dev/ttyACM*
USER_LIB_PATH = /home/ramces/Sketchbook/libraries/DHT/ dht.h
BOARD_TAG = uno
ARDUINO_LIBS = LiquidCrystal
include /usr/share/arduino/Arduino.mk
non-standard libraries are imported with the USER_LIB_PATH variable, however, the issue is that I don't know how to properly use USER_LIB_PATH. I looked at the documentation on git-hub but I am still not sure how USER_LIB_PATH is used correctly.
When I try loading the program to the Arduino microcontroller, with the command:
sudo make upload clean
the compilation stops with the error message:
/home/ramces/Sketchbook/libraries/DHT//dht.cpp:1: *** missing separator. Stop.
However, if I just leave the USER_LIB_PATH variable as:
USER_LIB_PATH = /home/ramces/Sketchbook/libraries/DHT
I get another error:
therm1.ino:2:17: fatal error: dht.h: No such file or directory
#include <dht.h>
^
compilation terminated.
/usr/share/arduino/Arduino.mk:1215: recipe for target 'build-uno/therm1.o' failed
make: *** [build-uno/therm1.o] Error 1
The documentation on using USER_LIB_PATH (https://github.com/sudar/Arduino-Makefile/blob/master/Arduino.mk) from git-hub has this:
# If you have your additional libraries relative to your source, rather
# than in your "sketchbook", also set USER_LIB_PATH, like this example:
#
# USER_LIB_PATH := $(realpath ../../libraries)
You don't have to move your DHT library. Use USER_LIB_PATH to specify the "root directory" where additional libraries are stored.
The libraries used are listed in ARDUINO_LIBS.
So the following should accomplish this:
USER_LIB_PATH = /home/ramces/Sketchbook/libraries/
ARDUINO_LIBS = LiquidCrystal dht
If you are running on Linux you need to be careful of the case of your folder/filenames... Linux (unlike windows) is case sensitive. ie
Sketchbook is NOT the same as sketchbook.
So is your Sketchbook folder
/home/ramces/Sketchbook/libraries/DHT
OR all lower case like
/home/ramces/sketchbook/libraries/DHT
The same applies to your DHT folder. What is the case of that folder?
So Check the CASE of your Files/foldernames.
One way I got around this issue is by moving my non-standard library dht.h along with another file that came with it dht.cpp into a new directory called dht which had to manually be placed inside the standard Arduino library directory as a root user otherwise permission to modify the standard Arduino library directory (located in: /usr/share/arduino/libraries) is denied. Also, I had to change the ARDUINO_LIBS variable to:
ARDUINO_LIBS = LiquidCrystal dht
since by default, ARDUINO_LIBS will check the standard Arduino libraries directory for any library specified in the variable ARDUINO_LIBS.
This does not solve the issue with USER_LIB_PATH, but it lets the user circumvent the issue of not being able to use a non-standard Arduino library for using certain sensors such as the humidity and temperature sensor library dht.h.The program was able to be compiled without issues and the sensor and LCD are now able to perform the program that was uploaded to the Arduino micro-controller.

Getting an syntax error by using RasPiArduino for Raspberry Pi

I am using an Raspberry Pi Zero with an L298n motor driver to control two motors. I was testing the motors using a Python script. That worked fine.
Now I wanted to use the Arduino software to program the motors. I was following this tutorial on how to archive that: https://www.youtube.com/watch?v=lZvhtfUlY8Y
Then I coded this into the Arduino software (v. 1.8.5)
void setup() {
// put your setup code here, to run once:
Console.println("Setup Einstellungen");
pinMode(17, OUTPUT);
delay(500);
Console.println("Setup Einstellungen Ende");
}
void loop() {
Console.println("Rechts Vorwärts");
digitalWrite(17, HIGH);
delay(1000);
digitalWrite(17, LOW);
delay(5000);
}
I compiled the file using "Export compiled Binary". I uploaded it on the Raspberry using FileZilla and tried to run it via SSH.
When I tried to run it with:
(sudo) sketch_feb28.ino.bplus.bin
I got the following error:
: -bash: syntax error near unexpected token `sketch_feb28.ino.bplus.bin'
Running file sketch_feb28.ino.bplus.bin
sketch_feb28a.ino.bplus.bin: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SY SV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2 .0, BuildID[sha1]=a0260345a3700dca64c63fde8a10959214ce9b85, not stripped
I cannot solve this issue alone.
I'm still not sure, where the syntax error comes from.
Run the file with:
./sketch_feb28.ino.bplus.bin
This is the syntax for running a binary, that is not in PATH. Since the file is a valid executable, the error message should vanish.

Processing to Arduino "IllegalAccessError"

I hope this exact issue was not addressed already. I did search for a while.
So I'm using the Arduino library for Processing, testing it by simply having it blink an LED that I have connected to my Arduino UNO. I'm following this tutorial, but am having a problem a little different than the ones covered on that tutorial page. Here's my Processing code:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
void setup()
{
//println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 57600); //error here
arduino.pinMode(ledPin, Arduino.OUTPUT);
}
void draw()
{
arduino.digitalWrite(ledPin, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(ledPin, Arduino.LOW);
delay(1000);
}
Here's my error:
IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Exception in thread "Animation Thread" java.lang.IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy
at cc.arduino.Arduino$SerialProxy.<init>(Arduino.java:119)
at cc.arduino.Arduino.<init>(Arduino.java:168)
at sketch_130206a.setup(sketch_130206a.java:29)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:680)
Since my error apparently has to do with access permissions, I tried doing what it says at the tutorial page I was following by going to /var/lock folder, but the /lock folder doesn't exist! I'm using a Mac 10.8.2. I searched around and found this thread (arduino dot cc/forum/index.php?topic=135164.0) and decided to try "sudo mkdir -p /var/lock" and "sudo chmod 777 /var/lock" in terminal, but it didn't change the error I have in Processing, even after restarting it. I also tried opening the Arduino app and uploading the StandardFirmata sketch as mentioned at the ProcessngxArduino library download page (playground.arduino dot cc/interfacing/processing) while trying to run the processing sketch, but same error. The fact that I'm using the Arduino UNO instead of the Duemilanove shouldn't be the issue as the UNO is apparently just an updated version of it. Any ideas what I could try to do next?
UPDATE: Okay so the highlighted error in my code is what opens the serial port I'm using at whatever rate (57600 bits/sec in this case I think). So I think the problem lies in this particular step in the instructions at the adrunio x processing info page mentioned earlier(playground dot arduino dot cc/interfacing/processing), step 3: "Configure Processing for serial: processing dot org/reference/libraries/serial/"... the link goes to processing's 'serial' reference page. I'm confused about what is meant by "configure"? How exactly do I figure out my "correct serial port"? I went through the rest of the instructions and the examples on the serial reference page, and still have no idea what I'm looking for.
UPDATE #2: My serial port for the arduino is "/dev/tty.usbmodem1411". I am still confused about how to plug this in to my code in Processing though. The things I just learned in these last 2 updates might be irrelevant to my error, I'm still unsure.
The problem was that I was using the beta version of Processing (2.0). Use the latest stable version (1.5.1) and it should work.

Resources