Posts | Comments

Planet Arduino

Archive for the ‘Library’ Category

Reading is big in Québec, and [pepelepoisson]’s young children have access to a free mini library nook that had seen better days and was in dire need of maintenance and refurbishing. In the process of repairing and repainting the little outdoor book nook, he took the opportunity to install a few experimental upgrades (link in French, English translation here.)

The mini library pods are called Croque-Livres, part of a program of free little book nooks for children across Québec (the name is a bit tricky to translate into English, but think of it as “snack shack, but for books” because books are things to be happily devoured.)

After sanding and repairs and a few coats of new paint, the Croque-Livres was enhanced with a strip of WS2812B LEDs, rechargeable battery with solar panel, magnet and reed switch as door sensor, and a 3.3 V Arduino to drive it all. [pepelepoisson]’s GitHub repository for the project contains the code and CAD files for the 3D printed pieces.

The WS2812B LED strip technically requires 5 V, but as [pepelepoisson] found in his earlier project Stecchino, the LED strip works fine when driven directly from a 3.7 V lithium-polymer cell. It’s not until around 3 V that it starts to get unreliable, so a single 3.7 V cell powers everything nicely.

When the door is opened, the LED strip lights up with a brief animation, then displays the battery voltage as a bar graph. After that, the number of times the door as been opened is shown on the LED strip in binary. It’s highly visual, interactive, and there’s even a small cheat sheet explaining how binary works for anyone interested in translating the light pattern into a number. How well does it all hold up? So far so good, but it’s an experiment that doesn’t interfere at all with the operation of the little box, so it’s all good fun.

There was a time when having a blinking blue LED on a project was all you needed to be one of the cool kids. But now you need something more complex. LEDs should not just snap on, they should fade in and out. And blinking? Today’s hotness is breathing LEDs. If that’s the kind of project you want, you should check out [jandelgado’s] jled library.

At first glance, an Arduino library for LED control might seem superfluous, but if you are interested in nice effects, the coding for them can be a bit onerous. If you don’t mind stopping everything while you fade an LED on (or off) then sure, you just write a loop and it is a few lines of code. But if you want to have it happen while other things continue to execute, it is a little different. The library makes it very simple and it is also nicely documented.

Obviously, to create a special effect LED, you need to create a JLed object. Then you can use modifier methods on that object to get certain effects. The only overhead is that you need to call the update method on the LED periodically. Here is one of the examples from the project:

#include <jled.h>

// connect LED to pin 13 (PWM capable). LED will breathe with period of
// 2000ms and a delay of 1000ms after each period.
JLed led = JLed(13).Breathe(2000).DelayAfter(1000).Forever();

void setup() { }

void loop() {

Pretty easy and readable. Just remember that some Arduinos can’t do PWM on pin 13, so you might have to adjust. Our only complaint is that you have to update each LED. It would be nice if the JLed constructor kept a linked list of all LED objects so you could have a class method that updates all of them with one call. In the examples, the author keeps all the LEDs in an array and steps through that. However, that would be easy to fork and add. Oh wait, we did it for you. The library does do a lot of work, including taking advantage of higher PWM resolution available on the ESP8266, for example.

The library can turn an LED on or off (including delays), blink or breathe an LED forever or for a certain number of times, or fade an LED on or off. In addition to the presets, you can provide your own brightness function if you want to do some kind of custom pattern. You can modify most actions by specifying a delay before or after, a repeat count (which can be forever) and you can also tell the library that your LED is active low, so you don’t have to mentally remember to flip everything around in your code.

Rocket science? No. But we like it. Blocking for an LED effect is bad and this makes fancy asynchronous LEDs simple. Why not use it? Recent IDEs can install it from the manage library dialog, so it takes just a second.

Really, libraries are a key to building systems simple. Why not stand on the backs of others? Some of our favorites handle SPI and proportional integral derivative (PID) control.

The WS2812 is an amazing piece of technology. 30 years ago, high brightness LEDs didn’t even exist yet. Now, you can score RGB LEDs that even take all the hard work out of controlling and addressing them! But as ever, we can do better.

Riffing on the ever popular Adafruit NeoPixel library, [Harm] created the WS2812FX library. The library has a whole laundry list of effects to run on your blinkenlights – from the exciting Hyper Sparkle to the calming Breathe inspired by Apple devices. The fantastic thing about this library is that it can greatly shorten development time of your garden-variety blinkables – hook up your WS2812s, pick your effect, and you’re done.

[Harm]’s gone and done the hard yards, porting this to a bevy of platforms – testing it on the Arduino Nano, Uno, Micro and ESP8266. As a proof of concept, they’ve also put together a great demonstration of the software – building some cute and stylish Christmas decorations from wood, aluminium, and hacked up Christmas light housings. Combining it with an ESP8266 & an app, the effects can be controlled from a smartphone over WiFi. The assembly video on YouTube shows the build process, using screws and nails to create an attractive frame using aluminium sheet.

This project is a great example of how libraries and modern hardware allow us to stand on the shoulders of giants. It’s quicker than ever to build amazingly capable projects with more LEDs than ever. Over the years we’ve seen plenty great WS2812 projects, like this sunrise alarm clock or this portable rave staff.
As always, blink hard, or go home. Video after the break.

Filed under: Arduino Hacks, Holiday Hacks, led hacks


Les Boites Mécaniques are a set of four automated boxes that produce music out of wood and metal. These experimental instruments enable anyone to explore the magic of making sound by pressing buttons on a remote, which activate each respective device to vibrate, knock, and rub materials.

The boxes were developed by Kogumi‘s Anatole Buttin and Yan Godat for educational electronic music workshops, and can be played either solo or in unison. There’s even a mode that allows users to control it all via MIDI notes on a computer.

In terms of hardware, each box is equipped with an Arduino Uno, a TLC59711 LED driver, step motors with AccelStepper library and a 3D-printed microstep driver.

Watch the video below to see how it all comes together to create a unique sound!


Increasing accuracy in the collection of data coming from sensors is a need that, sooner or later, Makers need to face. Paul Martinsen from MegunoLink created a tutorial to eliminate noise from sensor readings on Arduino with three simple filtering techniques.

The Averaging and Running Average techniques are easy to implement as they work by adding a number of measurements together, then dividing the total by the number of measurements. In both cases, the downside is that it can use a lot of memory.

The Exponential filter is a better solution for several reasons: it doesn’t require much memory, you can control how much filtering is applied with a single parameter, and it saves battery power because you don’t need to make many measurements at once. For this solution, they developed an Arduino filter library so you don’t need to go mad with math!


Interested? You can find the tutorial and explore the code on MegunoLing’s blog post here.

We’re still not sure exactly how [connornishijima]’s motion detector works, though many readers offered plausible explanations in the comments the last time we covered it. It works well enough, though, and he’s gone and doubled down on the Arduino way and bundled it up nicely into a library.

In the previous article we covered [connor] demonstrating the motion detector. Something about the way the ADC circuit for the Arduino is wired up makes it work. The least likely theory so far involves life force, or more specifically, the Force… from Star Wars. The most likely theories are arguing between capacitance and electrostatic charge.

Either way, it was reliable enough a phenomenon that he put the promised time in and wrote a library. There’s even documentation on the GitHub. To initialize the library simply tell it which analog pin is hooked up, what the local AC frequency is (so its noise can be filtered out), and a final value that tells the Arduino how long to average values before reporting an event.

It seems to work well and might be fun to play with or wow the younger hackers in your life with your wizarding magics.

Filed under: Arduino Hacks

Evil geniuses usually have the help of some anonymous henchmen or other accomplices, but for the rest of us these resources are usually out of reach. [Evan], on the other hand, is on his way to a helpful army of minions that will do his bidding: he recently built a USB-powered minion that turns a regular PS/2 mouse and keyboard into a Bluetooth mouse and keyboard.

[Evan] found his minion at a McDonald’s and took out essentially everything inside of it, using the minion as a case for all of the interesting bits. First he scavenged a PS/2 port from an old motherboard. An Arduino Nano is wired to an HC-05 Bluetooth chip to translate the signals from the PS/2 peripherals into Bluetooth. The HC-05 chip is a cheaper alternative to most other Bluetooth chips at around $3 vs. $40 for more traditional ones. The programming here is worth mentioning: [Evan] wrote a non-interrupt based and non-blocking PS/2 library for the Arduino that he open sourced which is the real jewel of this project.

Once all the wiring and programming is done [Evan] can turn essentially any old keyboard and mouse into something that’ll work on any modern device. He also put an NFC tag into the minion’s head so that all he has to do to connect the keyboard and mouse is to swipe his tablet or phone past the minion.

If you’re looking for an interesting case for your next project, this McDonald’s Minion toy seems to be pretty popular. PS/2 keyboards are apparently still everywhere, too, despite their obsolescence due to USB. But there are lots of other ways to get more use out of those, too.

Filed under: Arduino Hacks


Everyone knows Pong, the first commercially successful arcade video game machine  originally release by Atari in 1972. In those years the game helped to establish the video game industry and nowadays is often used by makers to experiment with creating game consoles with Arduino.

Roberto Melzi recently shared on the Arduino forum a new version of Pong made with Arduino Uno:

Thanks to the VGAx library done by Smaffer, based on the previous work done by Nick Gammon, I have done a little color game for an Arduino Uno working for a VGA monitor. See for details here:

The target was to use an Arduino Uno board without special shields and supporting IC.
the fundamental components are a button, a potentiometer, few resistors and DSUB15 connector.


Tale a look at the video to see it in action:


Follow the step-by-step guide on Instructables to build one yourself.


Marcelo Jimenez developed a library to use an Arduino as a JTAG programmer. Basically a Python script uploads a XSVF file to an Arduino which interprets it and performs the necessary JTAG manipulation in order to do the programming.

The project is pretty simple because it just uses  a few resistors and some wires and the library is included in the Arduino library manager or you can check it  on Github.

He also wrote an article to explain some JTAG, SVF and XSVF basics:

 I have recently felt the need to incorporate a JTAG port in a project to program a hardware that contained a CPLD. The idea was to both program it and perform some integrity tests on the board. I imagined something using pogo pins, to make it easier and quicker to test everything. I would also write the necessary test routines and generate some kind of report.

With this objective in mind, I have decided to design an Arduino shield to do the job. The testing routines were not really a big deal. And I was sure I would find some JTAG library for Arduino ready to be used. That was not the case.

There were some projects using Arduino to control a JTAG TAP (Test Access Port), but they were all incomplete. And I had no idea what was really JTAG. So I had to study a little bit to make things work for me.

In the end, the challenge proved enlightening. There were some caveats, both from hardware and from software. I’ll try to address them in this article.

Continue reading on his blog.



Strobe Remote

If you want to take a photograph with a professional look, proper lighting is going to be critical. [Richard] has been using a commercial lighting solution in his studio. His Lencarta UltraPro 300 studio strobes provide adequate lighting and also have the ability to have various settings adjusted remotely. A single remote can control different lights setting each to its own parameters. [Richard] likes to automate as much as possible in his studio, so he thought that maybe he would be able to reverse engineer the remote control so he can more easily control his lighting.

[Richard] started by opening up the remote and taking a look at the radio circuitry. He discovered the circuit uses a nRF24L01+ chip. He had previously picked up a couple of these on eBay, so his first thought was to just promiscuously snoop on the communications over the air. Unfortunately the chips can only listen in on up to six addresses at a time, and with a 40-bit address, this approach may have taken a while.

Not one to give up easily, [Richard] chose a new method of attack. First, he knew that the radio chip communicates to a master microcontroller via SPI. Second, he knew that the radio chip had no built-in memory. Therefore, the microcontroller must save the address in its own memory and then send it to the radio chip via the SPI bus. [Richard] figured if he could snoop on the SPI bus, he could find the address of the remote. With that information, he would be able to build another radio circuit to listen in over the air.

Using an Open Logic Sniffer, [Richard] was able to capture some of the SPI communications. Then, using the datasheet as a reference, he was able to isolate the communications that stored information int the radio chip’s address register. This same technique was used to decipher the radio channel. There was a bit more trial and error involved, as [Richard] later discovered that there were a few other important registers. He also discovered that the remote changed the address when actually transmitting data, so he had to update his receiver code to reflect this.

The receiver was built using another nRF24L01+ chip and an Arduino. Once the address and other registers were configured properly, [Richard's] custom radio was able to pick up the radio commands being sent from the lighting remote. All [Richard] had to do at this point was press each button and record the communications data which resulted. The Arduino code for the receiver is available on the project page.

[Richard] took it an extra step and wrote his own library to talk to the flashes. He has made his library available on github for anyone who is interested.

Filed under: Arduino Hacks, radio hacks

  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook