Hot answers tagged

11

You're right -- it doesn't work in most cases, and will almost always return true. The one board where it's actually functional is the Leonardo. According to the official documentation: On the Leonardo, if (Serial) indicates wether or not the USB CDC serial connection is open. For all other instances, including if (Serial1) on the Leonardo, this will ...


10

The code is also available online for those times you don't have the IDE installed: https://github.com/arduino/Arduino


10

I did essentially the same thing with getting the Adafruit ST7735 library working in chipKIT. I started a support thread here which can lead you through my process. I tackled it the same way I do general programming: 1-» Copy over Libraries, get it so your compiler can actually SEE them. 2-» Start trying to compile and then triage errors from the "top level"...


9

The base Arduino source files are in the Arduino installation, under hardware/*/cores/. Source for additional libraries included are in libraries/. Additional files may be found in the sketchbook under its hardware/*/cores/ and libraries/ directories.


9

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 pass the Stream object you want to actually communicate: #include "Arduino.h" class MyProtocol { public: MyProtocol(Stream& s):serial(s){} void ...


8

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.


8

Microsmooth is a lighweight signal smoothing library currently being developed by me. It is still being worked on and the aim is to make it lightweight in terms of memory and fast. The library provides multiple filters for smoothing: Simple Moving Average Exponential Moving Average Cumulative Moving Average Savitzky Golay Filter Ramer Douglas Pecker ...


7

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 pass filter, moving average, weighted moving average, etc. in terms of its response time and its ability to ignore such single-sample noise spike outliers). ...


7

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. You use soft or hard links to the files in the project (look up the man pages on "ln"). But,... talk about ugly! So the question is how to do it "correctly"? ...


7

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 the shoulders of giants! Several message serialization protocols exist. BSON MessagePack Protocol Buffers CBOR (Concise Binary Object Representation) ... ...


6

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 object is and initialize it. That way if you want to use the same class on a hardware UART instead of a SoftwareSerial you just change the sketch, not the ...


6

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 entirely new copy of the function. This can only work if the functions are static, which means that they exist, and are contained entirely within, the function in ...


6

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 initialization lists to keep things simple. For example: class Something { uint8_t _cs; uint8_t _dc; Something(uint8_t cs, uint8_t dc) : _cs(cs), _dc(dc) ...


6

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 a separate (e.g. Init) method. Advantages: Can be dynamically changed Remarks For pin settings, mostly static circuits are used so the first approach is ...


5

After further digging, this appears to be from Mikal Hart's Flash library. The reason this library was developed is: Storing static program data in flash/PROGMEM is a tricky part of Arduino programming. To save precious RAM, a novice user already at odds with unfamiliar C++ syntax must digest such daunting concepts as prog_char, PSTR(), PROGMEM, ...


5

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 larger the conductive surface, the higher the capacitance. The further apart the conductors, the smaller the capacitance. Using a higher resistance means that you ...


5

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 are at the top right of the Arduino site. When you first go to edit a Playground page you'll be taken to a "Password required" page but don't worry, this is only ...


5

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. Several alternative IDEs already support Arduino, typically via plugins which handle a lot of the details automatically. I normally recommend Eclipse as it's a ...


5

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); In the file max7456.cpp at line 484 change it from: void Max7456::getCARACFromProgMem(const prog_uchar *table, byte i, charact car) to: void Max7456::...


5

Interrupt Service Routine (ISR) outside a class Let's consider a simple use of interrupts: volatile bool switchChanged; void switchPressed () { switchChanged = true; } // end of switchPressed void setup () { pinMode (2, INPUT_PULLUP); attachInterrupt (0, switchPressed, CHANGE); } // end of setup void loop () { // whatever } // ...


5

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 and there and using Arduino's "IDE". Calling programs "sketches" and manipulate it to hide, that it is in C++. And so on and so on. If you want to make more ...


5

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 from the official Arduino page.


5

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 use. So you can provide a constructor with a Stream object alone and use that: class Foo { private: Stream *_dev; public: foo(Stream *dev) : ...


4

Have you tried a low pass filter? I found an example here an another one here. Both of these libraries have a list of data being read from the analog sensor of your choice which is averaged. Every new sensor value is added to the list, and the last one is thrown out, like this: List: 3 4 3 3 4 3 5 3 2 3 4 3 new reading added. old one thrown out /-- ...


4

The typical way to achieve what you want would normally be to create your own subclass of OneWire class and override the methods you need to change, then pass a pointer to an instance of your class to the DallasTemperature constructor. However, for this to work, the OneWire class must have been developed with extensibility (subclassing) in mind, i.e. use ...


4

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 Windows, that's normally C:\Users\UserName\Documents\Arduino\libraries), when you want to use that library with Arduino IDE, you must add the library for your sketch ...


4

The flash array is from Mikal Hart's flash library as you show, and what it does is that they declare an array or a matrix (table) object in the PROGMEM memory: #define FLASH_ARRAY(type, name, values...) \ static const type name##_flash[] PROGMEM = { values }; \ _FLASH_ARRAY<type> name(name##_flash, sizeof(name##_flash) / sizeof(type)); which is an ...


4

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 manager works here: https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ There isn't however an official website listing the libraries, so I recently ...


4

You just described the problems the company I'm working for is trying to solve. We've recently launced a product called biicode. It seems exactly what you are looking for. biicode is both an online central repository for code and and a client tool that features: Easy to use by beginners, configurable for more advanced users Dependencies resolution, ...


4

While it may not be possible to detect whether a device is connected to the Arduino serial connection or not, it is possible to enable the debug messages over the serial connection based on the presence of a device on the serial connection. Considering that you will be using the debug interface of your sketch only when connected to a computer capable of ...


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