Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

13 votes

How can I get the source files for Arduino libraries?

The code is also available online for those times you don't have the IDE installed: https://github.com/arduino/Arduino
user avatar
  • 5,170
10 votes
Accepted

Writing First Library - Serial Stream Object

Here is a simple example (built and tested with a mega2560), with a class that can be passed a Stream object, and sends a Hello over this generic stream object. When constructing the object, you can ...
user avatar
  • 1,364
10 votes
Accepted

How can I get the source files for Arduino libraries?

The base Arduino source files are in the Arduino installation, under cores/arduino/. Source for additional libraries included are in libraries/.
user avatar
9 votes

How can I get the source files for Arduino libraries?

On a Mac, the path to the source code folder is: Arduino.app/Contents/Resources/Java/Hardware/Arduino/Cores/Arduino. I'd expect it would be the same from /Java/ on down in other OSes.
user avatar
  • 14.4k
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 ...
user avatar
  • 221
7 votes

Are there any signal smoothing libraries for Arduino?

I think I see a lot of single-sample noise spikes in your noisy signal. The median filter does better at getting rid of single-sample noise spikes than any linear filter. (It is better than any low ...
user avatar
  • 1,051
7 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. ...
user avatar
7 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 ...
user avatar
  • 1,300
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
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 ...
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 ...
user avatar
  • 101k
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 ...
user avatar
  • 101k
5 votes
Accepted

Why does increasing resistance make a capacitive sensor more sensitive?

A capacitor is created from two conductors with a dielectric between them. The capacitance of the capacitor is determined by the surface area of the conductors and the distance between them. The ...
user avatar
5 votes
Accepted

How to avoid odd naming rules for Arduino when writing a library?

Yep, the Arduino IDE kinda sucks eventually. There is no best practise really, as Arduino *.ino files aren't proper c / c++ anyway. I would hope that people who know how to write C++ classes (as ...
user avatar
  • 2,886
5 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 ...
user avatar
  • 223
5 votes
Accepted

How to share a library on Arduino Playground?

The Arduino Playground library list is a wiki page (like everything on the playground). That means anyone can log in to edit it and add links to their own libraries. The "Log In" and "Sign Up" links ...
user avatar
5 votes

Writing C Program outside of Arduino IDE?

You're absolutely right about needing to link against other libraries. However, you don't necessarily need to worry about all of the details yourself, unless you want/need to do something unusual. ...
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)...
user avatar
  • 35.1k
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 ...
user avatar
  • 35.1k
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 ...
user avatar
  • 1,352
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 ...
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 ...
user avatar
  • 1,645
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.
user avatar
  • 35.1k
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 ...
user avatar
  • 66
4 votes
Accepted

Arduino error message that I don't understand

It seems to me that those Adafruit libraries were not correctly installed on your PC or your sketch. In addition to downloading and installing the library onto the Arduino library directory (on ...
user avatar
  • 8,809
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 ...
user avatar
  • 141
4 votes
Accepted

error: ‘sleep’ was not declared in this scope

"sleep()" is not a function on arduino. The sleep.h file contains functions for the hardware sleep functionality used to reduce power consumption when processing isn't necessary. "delay()" is the ...
user avatar
  • 4,309
4 votes

Arduino standard libraries location

Ok, i found out the location. In Win 7, it is C:\Program Files (x86)\Arduino\libraries
user avatar
  • 1,315

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