Hot answers tagged

42 votes
Accepted

Warning when verifying sketch with VS code

Thanks to @Majenko I looked some place new: documented in the arduino plugin of VS Code Arduino Extension there is an option to set an output directory. Note though that according to this it should ...
Uwe Hafner's user avatar
30 votes

How to compile, upload and monitor via the Linux command line?

I use the command-line interface to the arduino command. I run it like this: arduino --upload sketch/sketch.ino --port /dev/ttyUSB* There is a page which describes other command-line tools, like ...
Metamorphic's user avatar
29 votes

Warning when verifying sketch with VS code

To clarify the answer, for those new in arduino world +StudioCode (source: https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino ) The following settings are as per sketch ...
Mirosław Drdzeń's user avatar
14 votes
Accepted

Will a .ino Arduino Sketch compile directly on GCC-AVR?

See my answer here: Classes and objects: how many and which file types do I actually need to use them? - specifically: How the IDE organizes things. I know that at a minimum you have to include the ...
Nick Gammon's user avatar
  • 37.6k
12 votes

Will a .ino Arduino Sketch compile directly on GCC-AVR?

I would just like to add a few points to Nick Gammon's answer: You do not need to rename a .ino file in order to compile it: if you explicitly tell the compiler it's C++ (option -x c++), it will ...
Edgar Bonet's user avatar
  • 41.4k
11 votes

How to compile, upload and monitor via the Linux command line?

I would suggest Googling for Makefile projects. I did one a while back for the Blink program, by basically seeing what got generated by the IDE and replicating that in a more general way. # # Simple ...
Nick Gammon's user avatar
  • 37.6k
8 votes
Accepted

How can I have code in a project that won't compile for Arduino?

I would use conditional compilation, like this: #ifndef(ARDUINO) // Non-Arduino code. #endif
Edgar Bonet's user avatar
  • 41.4k
7 votes
Accepted

Why does this code execute?

If you add a debugging print you will see what is happening: void setup() { Serial.begin (115200); Serial.println (); pinMode(13, OUTPUT); int len = 5000; byte *data = (byte *)malloc(len *...
Nick Gammon's user avatar
  • 37.6k
7 votes
Accepted

Is there a way to upload precompiled code to an arduino?

Is there a way to compile arduino code without automatically uploading it, so that I can put the pre-compiled binary up for download on a website? Yes, you can save the .hex file produced by the ...
Mikael Patel's user avatar
  • 7,959
7 votes
Accepted

Using Arduino as a standalone compiler

First of all: The Arduino IDE brings its own GCC compiler. It is a version, that can compile for the AVR platform (don't know, if the standard version is capable of that). When you activate verbose ...
chrisl's user avatar
  • 15.6k
7 votes

Program size optimization

Using the Serial object pulls HardwareSerial0.o into your program linkage. This file defines, among other things, the ISRs (interrupt service routines) associated with the serial port. ISRs are ...
Edgar Bonet's user avatar
  • 41.4k
6 votes

How to compile, upload and monitor via the Linux command line?

What you need is a Makefile. There are a few Makefile projects around for Arduino. Googling for "Arduino Makefile" returns many results including what looks like a good one on Github: https://github....
Majenko's user avatar
  • 105k
6 votes

How to compile, upload and monitor via the Linux command line?

Official CLI tool The arduino team is developing a cli client https://github.com/arduino/arduino-cli Announcement: https://blog.arduino.cc/2018/08/24/announcing-the-arduino-command-line-interface-...
Madacol's user avatar
  • 161
6 votes

My Digispark board won't show up in Ports tab in Arduino IDE (OSX)

I don't think it is supposed to. The Digispark briefly connects in "bootloader" mode, which you spotted as "Vendor-Specific Device:". Then after 5 seconds it runs the loaded sketch. If your sketch ...
Nick Gammon's user avatar
  • 37.6k
5 votes

How to include <SPI.h> outside the .ino file

See my answer How the IDE organizes things. There is no easy way to avoid having to put an include in the main .ino file, unless you write your own build process (or perhaps use another toolchain). I ...
Nick Gammon's user avatar
  • 37.6k
5 votes
Accepted

How to properly understand verbose compiler error text? For beginner level

As @st2000 said, it's best to start with the first error shown as that error may be causing other errors that will go away once you fix the first one. You should be aware of the difference between ...
per1234's user avatar
  • 4,048
5 votes
Accepted

Project wont compile when I place functions below function calls

You need to declare your function before you use it. So either the whole function body needs to be before the usage, or you must add a function prototype declaration. void myfunction(); myfunction()...
David Jones's user avatar
4 votes
Accepted

LCD 16*02 I2C shield only shows first character printed

That's definitely a bug appeared in 1.6.6. For reference, see https://blog.arduino.cc/2015/11/03/arduino-ide-1-6-6-released-and-available-for-download/#comment-278766 https://forum.arduino.cc/index....
AFract's user avatar
  • 193
4 votes
Accepted

fatal error: avr/io.h: No such file or directory

The Due is SAM architecture. avr/io.h is specific to the AVR architecture of the Uno's microcontroller. The compiler will not look in the avr tools folder for that file and even if it did it wouldn't ...
per1234's user avatar
  • 4,048
4 votes

Random "Compilation error: Error: 13 INTERNAL: exit status 1". No clue how to resolve or even what causes this error

The problem with that error message is that you are only reading the very last line. That line says "Oops, it didn't compile". The actual error message occurs before that. You need to read ...
Majenko's user avatar
  • 105k
4 votes
Accepted

How to cut down size of imported DigiKeyboard library

With input from @EdgarBonet, I looked into the functions used and it turned out that the String() function, I used once in my code, takes up about 3kB of space in the compiled program. I ended up ...
emma.makes's user avatar
4 votes

Break a big file into smaller files

This is not the right way to split a big .ino file. You should instead think in terms of functional units, i.e. software “modules” that address specific concerns. For example, if a subset of your code ...
Edgar Bonet's user avatar
  • 41.4k
3 votes

LCD 16*02 I2C shield only shows first character printed

Your code contains, in part, #include <LiquidCrystal_I2C.h> .... LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { lcd.init();...
James Waldby - jwpat7's user avatar
3 votes

Basic makefile for avr-gcc

The accepted answer is great as it has given me a valuable lesson in all kinds of debugging tools (avr-objdump -D has become a close friend). Namely, the line: ${OBJCOPY} -O ihex -R .eeprom $< $@ ...
Robert Špendl's user avatar
3 votes

Compiling is slow

I had the same problem until today. Like many answers around the web, the problem seems to come from the anti-virus. My setup is Windows 10 x64 with a SSD and I use Windows Defender as the AV. I ...
NickB's user avatar
  • 131
3 votes

How can I make Arduino IDE use Atmel's provided toolchain? (Linux/Ubuntu)

In the directory for the new core create a new platform.txt and give the entry for compiler.path the location of the bin/ directory containing the Atmel toolchain. compiler.path=/path/to/bin/
Ignacio Vazquez-Abrams's user avatar
3 votes
Accepted

How to include <SPI.h> outside the .ino file

It seems that I am obliged to include SPI.h only from the ino file. But why? And how can I do what I want here? do I have to change IDE? The background is how the Arduino IDE pre-processor works ...
Mikael Patel's user avatar
  • 7,959
3 votes

No power_usi_disable() on Arduino Uno

The Arduino Uno does not have a USI peripheral. Thus, you cannot disable the power of the (non-existent) USI, and there is no power_usi_disable() function. Solution: remove the call to ...
Edgar Bonet's user avatar
  • 41.4k
3 votes

How to change Arduino Nano MODEL_ID

Finally find the solution =) You don't have to change the ID vendor or ID product: it is possible to attribute a permanent name with devpath (where the device is plugged) The only downside of using ...
lestage laurent's user avatar
3 votes

Referencing local libraries from higher dir levels

The problem with a relative path for an include is that it has to be relative to one of the predefined list of existing include directories. This includes: Compiler include locations The Arduino core ...
Majenko's user avatar
  • 105k

Only top scored, non community-wiki answers of a minimum length are eligible