Hot answers tagged

8 votes

Loading local libraries

Okay, here is how it works, and I checked it to make sure. Sure you can use hard paths, but every programmer hates using hard paths. They are not portable at all, and they lock your program in place. ...
Sean Walton's user avatar
8 votes

Binary message formatter

Passing messages across computers and/or microcontrollers with different architectures can be a real pain (endianness...). So do not fall into NIH / reinventing the wheel traps but keep standing on ...
scls's user avatar
  • 221
8 votes
Accepted

How to manage dependencies?

Arduino is meant to be easy way for non-technical people and so it hides as much as it can from plain view to be simple. For simple project it works at the cost of overhead of copying libraries here ...
gilhad's user avatar
  • 1,380
8 votes
Accepted

Include guards vs #pragma once

#pragma once operates on the absolute filename of a file. Include guards work on the content of the file. If you have multiple copies of the same library (maybe one library has some parts of another ...
Majenko's user avatar
  • 105k
6 votes

Where can I find a central repository of all available Arduino libraries?

Since this question was first asked, there is now the Arduino Library Manager, built into the Arduino IDE. There you can search for and install libraries. There is information about how the library ...
njh's user avatar
  • 243
6 votes

How to define a SoftwareSerial object inside a class?

Personally I wouldn't go down this route. Instead I would pass a Stream object (as a pointer or a reference) to the constructor and use that. Then it is up to your sketch to define what that Stream ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Collection of functions for arduino IDE

You need to "split" your library. Placing full functions inside a header file (.h) is bad form and causes the exact problem you are seeing. Every time you include the header file you create an ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Multiple definition of "..." Compiler Error

Although the motor (global) variables are defined in a header files, they are included in both cpp files, thus defined twice. Make them extern, and than define them in the motor.cpp file. In motor.h,...
Michel Keijzers's user avatar
6 votes
Accepted

What is the proper way to make library pin mappings configurable?

The method I use is to provide the pins as parameters to the constructor. Those pin numbers are stored in variables to use later in the .begin() function and elsewhere. Most of the time I use ...
Majenko's user avatar
  • 105k
6 votes

What is the proper way to make library pin mappings configurable?

I would use either of the following two possibilities: Use (class) variables and set them within the constructor. Advantages: Always initialized Easy to use (constructor and pin setup at once) Use ...
Michel Keijzers's user avatar
6 votes

How to write a library that support both HW and SW Serial communication and allow user to chose which one to use?

The trick here is to go "up a level". Both HardwareSerial and SoftwareSerial inherit from the Stream class. It is that class that provides the majority of the interface that you actually ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Recommended way to fork a library

Almost. Fork the library to your account Check out your fork Edit as needed Commit locally Push back to your fork Your fork is yours to do with as you wish. Github makes it easy, should you wish, to ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Which Arduinos support ATOMIC_BLOCK?

This answer covers: Which Arduinos support ATOMIC_BLOCK? And how can I duplicate this concept in C with __attribute__((__cleanup__(func_to_call_when_x_exits_scope))) and in C++ with class constructors ...
Gabriel Staples's user avatar
5 votes
Accepted

Updating MAX7456 library to work with Arduino 1.6.6

In the file max7456.h at line 228 change it from: static void getCARACFromProgMem(const prog_uchar *table, byte i,charact c); to: static void getCARACFromProgMem(const char *table, byte i,charact c)...
Nick Gammon's user avatar
  • 37.6k
5 votes

Loading local libraries

I recently tested this local library structure. It works with: #include "libs/MyNewLib/MyNewLib.h" The Arduino IDE 1.6.7 build pre-processing will even pick up the source code for the library. ...
Mikael Patel's user avatar
  • 7,959
5 votes
Accepted

Pass class's public function as an argument to external command

Interrupt Service Routine (ISR) outside a class Let's consider a simple use of interrupts: volatile bool switchChanged; void switchPressed () { switchChanged = true; } // end of ...
Nick Gammon's user avatar
  • 37.6k
5 votes
Accepted

Are there any constants for default SPI port pins defined?

Yes there are. They are defined in pins_arduino.h Below the pins for the yun. // Map SPI port to 'new' pins D14..D17 static const uint8_t SS = 17; static const uint8_t MOSI = 16; static const ...
jantje's user avatar
  • 1,372
5 votes
Accepted

How to measure resistance of TFT Touchscreen

As pointed out in other answers and comments, step one was trying to get a datasheet for this component. I couldn't find a datasheet for the shield, but here is the link from the vendor I bought it ...
jotadepicas's user avatar
5 votes
Accepted

Ubuntu class string has no member remove

The remove method was added to the String class in 1.0.6. Installing Arduino IDE from the Ubuntu repository gets you a really old package (1.0.5). You should download and install the newest version ...
gre_gor's user avatar
  • 1,680
5 votes
Accepted

Is it possible to use mathematical sets and their operations in arduino?

The Standard Template Library (STL) can be installed on the Arduino. It is not there by default. That includes things like sets. One implementation is here.
Nick Gammon's user avatar
  • 37.6k
5 votes
Accepted

Undefined reference to function in custom library

I suspect you're compiling from C++ code, and including that header. When C++ links to C code, the C++ code needs to see extern "C" on the declaration, or surrounding the declaration (via ...
Bob's user avatar
  • 66
4 votes

How can I get the source files for Arduino libraries?

The arduino source files can be found on Github at https://github.com/arduino/Arduino, however the libraries have been moved to their own repositories: https://github.com/arduino/ArduinoCore-avr ...
JBaczuk's user avatar
  • 141
4 votes

Alternatives to Wire library for I2C

Also Procyon AVR library worth be checking. It is a bit old now but very professional and kinda minimalistic. Not much dependencies, should be fine to use just I2C module only. There is hardly ...
Flanker's user avatar
  • 529
4 votes

Alternatives to Wire library for I2C

I don't see any objection to using DSS Circuits I2C Master Library. It may not have been updated for a couple of years, but if it works it doesn't need to be. It's not as if libraries for micro-...
Nick Gammon's user avatar
  • 37.6k
4 votes

How to develop or edit an Arduino library?

I'm not accepting any answer because they are only focused on versioning/git/github fork->edit->share and I am very interested on all the things that I have to do to make the development. I will run ...
Nick Gammon's user avatar
  • 37.6k
4 votes

Convert library from using bitbanging to hardware SPI

The standard AVR library has SPI handling. See, for example: http://www.gammon.com.au/spi You don't have to write a library if you don't want, just communicate directly using SPI. The datasheet for ...
Nick Gammon's user avatar
  • 37.6k
4 votes
Accepted

Can I prevent the Stepper library from holding the motor?

use disable output class in accelstepper library. http://www.airspayce.com/mikem/arduino/AccelStepper/
Mehis Laane's user avatar
4 votes

Are there any detail examples of Si4463

I've looked at the data sheet for this and I think it is the wrong choice of device for a beginner. Can I suggest that you start by looking at a relatively simple DPI interfaced device, such as a ...
Code Gorilla's user avatar
  • 5,627
4 votes

Is there a way to replace an Arduino core function without modifying the Arduino code?

Not sure about the Arduino IDE (I don't have it installed right now) but using UECIDE it's as simple as defining a new digitalWrite function in your code. When the whole shebang gets linked together ...
Majenko's user avatar
  • 105k
4 votes
Accepted

Error saying an included library is not

I see you are using an Arduino Uno. An Arduino Uno cannot act as a USB keyboard - therefore the Keyboard library doesn't exist for it (the file Keyboard.h is seen as being empty). You can only use ...
Majenko's user avatar
  • 105k

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