10
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 ...
7
votes
Accepted
is #ifdef __SD_H__ considered a bad practice?
Yes, it is in general a bad practice to use include guard define to detect if the header file is included. It will work only in a header file in a compilation unit which includes the detected header ...
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 ...
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 ...
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 ...
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 ...
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.
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 ...
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
https:...
4
votes
Accepted
Higher precision logarithms
You should be able to get 6 or 7 decimal places out of the Arudino float type. Try using Serial.print for floats with a number of decimal places. Something like this:
float x = log10(3.141592658);
...
4
votes
Accepted
Use ISRs inside a library more elegantly
As a matter of efficiency, I would favor chrisl’s advise to use the
platform's low-level interrupts if at all possible. This, however, comes
at the cost of portability: you would need an ...
4
votes
Error in defining Ticker in ESP32 library
ESP32 ticker attach functions take pure function pointers with at max one argument type -- not a std::function/ std::_Bind_helper that std::bind produces.
See code and types at https://github.com/...
4
votes
Accepted
Programming Arduino Uno R3 to trigger a relay once every 24 hours
Yes, the delay() will work, as will other methods based on the millis() counter. However, delay() will make it impossible to do something else in the meantime.
Look up Blink without delay for an ...
4
votes
Accepted
Library for working with a 4-digit 7-segment indicator SH5461AS
This one tm1637 sounds good. I was thinking to use it next time.
Edit 1:
Lately posted image suggests that it is without a separate display controller chip, then this library should work.
Edit 2:
...
4
votes
Accepted
which is the best way to declare Serial while creating Arduino library?
As regards the use of Stream:
I usually use Stream instead of HardwareSerial because:
It allows the use of other serial devices, like SoftwareSerial or USBSerial that aren't "Hardware" ...
4
votes
Accepted
TVout characters don't line up
I believe your problem is in this line:
if (++tmpx == c + 2) {
Here you are mixing two different things:
c is a character code, i.e. the index of a glyph within the
expr8x8 font
tmpx is the index of ...
4
votes
Accepted
Trying to resolve invalid conversion from 'byte' {aka 'unsigned char'} to
In C and in much pre-standard C++ nothing stops you just assigning an integer value to a variable of enumeration type. In standard C++ (from 1998 onward) that requires an explicit type conversion (a &...
4
votes
Accepted
Uploading a Library to the library manager from a Github branch
No. As stated in the instructions for submitting a library to the Arduino Library Manager registry, the URL must be to the home page of the repository.
The way the Library Manager index generation ...
3
votes
Accepted
RadioHead and DallasTemperature error
I have experienced many issues when using RadioHead library on ATTiny85 together with the Arduino IDE. Your issue is not the Dallas temp sensor.
The problem lies in that RadioHead uses timer 0 on the ...
3
votes
Error: `nullptr` was not declared in this scope. Arduino IDE
I installed Arduino IDE in two different ways (only god knows why). The first one was via using of manager apt-get and other was manually via downloading, unzipping and installation through the ...
3
votes
Accepted
Save a fingerprint to the database of the fingerprint sensor
The sizeof() operator doesn't do what you think it does. It's not a function that is executed at runtime, it's an operator that is interpreted at compile time.
It takes a variable and returns the ...
3
votes
Accepted
Trying to make sense of the coding style in Arduino libraries. (Particularly the Radiohead library)
They're not defined. If you notice that whole block is wrapped in a #ifdef which will be false unless you're on some specific platform, where the platform defines those macros.
Everything else uses ...
3
votes
Arduino Libraries: Declaring variables as public?
The Arduino ecosystem is meant mostly for beginners. This often means that people with very little knowledge will be using it and will often try random things to make stuff work. (and once they found ...
3
votes
Accepted
Specified folder/zip file does not contain a valid library
That's because it contains two libraries, and the IDE doesn't know how to handle that.
Because of this repository structure, you will need to do a manual installation.
Extract the zip file manually ...
3
votes
Accepted
How to install your own library with Arduino IDE 1.8.5?
You need to:
Create the folder ~/Arduino/libraries/MyLibrary
Place the library files in there named as:
~/Arduino/libraries/MyLibrary/MyLibrary.h
~/Arduino/libraries/MyLibrary/MyLibrary.cpp
Restart ...
3
votes
Accepted
Standard Practice for including custom library in examples folder
You can use either. There is no "standard".
When using a raw C compiler there is a difference between the two as regards the order in which directories are searched for files to include, but with the ...
3
votes
Guideline in library creation
Where to put additional libraries (such as <Wifi.h>) in .h or .cpp, since it works when defined in each one of them?
Any library can reference any other library. So including another library ...
3
votes
exit status 1 - expected primary-expression before '(' token
You have tried to define void midi() {...} inside the loop() function. But you cannot nest function definitions. Your definition (implementation) of midi() should be outside any other function.
Like ...
3
votes
Accepted
Not able to find right library for MPU9250
In the Arduino IDE, click on SKETCH > INCLUDE LIBRARY > MANAGE LIBRARIES.
Then, search for 9250, select the SparkFun one, and click INSTALL.
Finally, from the examples, choose the MPU9250BasicAHRS_I2C....
3
votes
Accepted
Bit Number to Byte Value conversion (AVR Docs)
The bits within a byte are numbered 0 through 7 from right to left. The
rightmost (least significant) is bit 0, next is bit 1... and the
leftmost (most significant) is bit 7.
The expression _BV(3) ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
library × 532arduino-uno × 102
arduino-ide × 61
programming × 54
c++ × 52
esp8266 × 24
arduino-mega × 24
class × 24
serial × 23
sensors × 21
arduino-nano × 19
adafruit × 18
compile × 18
timers × 17
esp32 × 16
lcd × 16
compilation-errors × 14
i2c × 13
core-libraries × 13
display × 12
ide × 12
wifi × 10
spi × 10
pins × 10
c × 10