Posts | Comments

Planet Arduino

Archive for the ‘servo’ Category user [peterquinn] has encountered a problem with his recently unruly cat peeing under the dining table. Recognizing that the household cat’s natural enemy is the spray bottle, he built an automatic cat sprayer to deter her antics.

The build is clear-cut: an Arduino Uno clone for a brain, an MG995 servo, PIR sensor, spray bottle, and assorted electronics components. [peterquinn] attached the servo to the spray bottle with a hose clamp — ensuring that the zero position is pointing at the trigger — and running a piece of cabling around the trigger that the servo will tug on. Adding a capacitor proved necessary after frying the first Uno clone, as the servo powering up would cause the Uno to reset.

The code is set up to trigger the servo — spraying the cat twice — once the PIR detects the cat for more than ten seconds. After toying with a few options, [peterquinn] is using a 9V, 2A power supply that works just fine. For now, he hopes the auto-sprayer should do the trick. If it somehow doesn’t work, [peterquinn] has mused that a drastic upgrade to the vacuum may be necessary.

A robot assistant would make the lives of many much easier. Luckily, it’s possible to make one of your own with few fancy materials. The [] team demonstrates this by building a robot arm out of recyclables!

With the exception of the electronics — an Arduino, a trio of servo motors, and a joystick — the arm is made almost completely out of salvaged recyclables: scrap wood, a plastic bottle, bits of plastic string and a spring. Oh, and — demonstrating yet another use for those multi-talented tubers — a potato acts as a counterweight.

Instead of using screws or glue, these hackers used string made from a plastic bottle as a form of heat shrink wrap to bind the parts of the arm together. The gripper has only one pivoting claw for greater strength, and the spring snaps it open once released. Behold: your tea-bag dunking assistant.

Code for the project is available to download from their site. Given this straightforward tutorial, it’s hard to find a reason NOT to embark on building your first robot arm — if you haven’t already begun.

We at Hackaday love seeing projects that strive to reuse materials in inventive ways. That said, you needn’t rely on a shiny new Arduino for this robot arm. If you have an aging palm pilot kicking around, that will also do the trick.

Filed under: Arduino Hacks, hardware, robots hacks

It is pretty easy to go to a big box store and get a digital speedometer for your bike. Not only is that no fun, but the little digital display isn’t going to win you any hacker cred. [AlexGyver] has the answer. Using an Arduino and a servo he built a classic needle speedometer for his bike. It also has a digital display and uses a hall effect sensor to pick up the wheel speed. You can see a video of the project below.

[Alex] talks about the geometry involved, in case your high school math is well into your rear view mirror. The circumference of the wheel is the distance you’ll travel in one revolution. If you know the distance and you know the time, you know the speed and the rest is just conversions to get a numerical speed into an angle on the servo motor. The code is out on GitHub.

Granted, reading a magnet, keeping time, and driving a servo isn’t exactly cutting edge. On the other hand, it made us think about what other kinds of outputs you could drive. We haven’t seen a nixie tube speedometer (well, not on a bicycle, anyway), for example. Or maybe one built with mechanical flip numbers like an old clock.

We have seen some with Arduinos and lots of LEDs (although, again, not really for a bicycle). This speedometer might still be our favorite, though.


Filed under: Arduino Hacks, transportation hacks

Desk toys are perfect for when you don’t want to work. There’s a particularly old desk toy called the Newton’s cradle. If you don’t know the name, you’d still recognize the toy. It is some ball bearings suspended in midair on strings. If you pull back, say, two balls and let them swing to impact the other balls, the same number of balls on the other side will fly out. When they return, the same number will move on the other side and this repeats until friction wears it all down.

We think [JimRD] might be carried away on procrastination. You see, he not only has a Newton’s cradle, he has automated it with an Arduino. According to [Jim], this is his third attempt at doing so. You can see the current incarnation in the video, below.

There are two servos. One pulls back the balls and releases them and the other stops the balls in anticipation of the next operation. The servo that pulls the balls back is clearly magnetic. At first, we thought it was an electromagnet and that deenergizing it released the balls. That’s not the case. Instead, the servo arm has a permanent magnet, but foam decouples it from the ball so that if the arm pulls far enough away, the ball can escape.

Because of the differences in magnets, ball bearings, and other factors, if you try to duplicate this, you’ll probably have to experiment a little with the angles and speeds in the code. The ball stop servo is probably unnecessary, as long as you don’t mind waiting for the thing to wind down on its own.

If you don’t have a cradle, you could always make one yourself. We’d probably avoid using light bulbs, though.

Filed under: Arduino Hacks

Space. The final frontier. Unfortunately, the vast majority of us are planet-locked until further notice. If you are dedicated hobbyist astronomer, you probably already have the rough positions of the planets memorized. But what if you want to know them exactly from the comfort of your room and educate yourself at the same time? [Shubham Paul] has gone the extra parsec to build a Real-Time Planet Tracker that calculates their locations using Kepler’s Laws with exacting precision.

An Arduino Mega provides the brains, while 3.5-turn-pan and 180-degree-tilt servos are the brawn. A potentiometer and switch allow for for planet and mode selection, while a GPS module and an optional MPU9250 gyroscope/magnetometer let it know where you are. Finally a laser pointer shows the planet’s location in a closed room. And then there’s code: a lot of code.

The hardware side of things — as [Shubham Paul] clarifies — looks a little unfinished because the focus of the project is the software with the intent to instruct. They have included all the code they wrote for the RTPT, providing a breakdown in each section for those who are looking to build their own.

There is an extra step to auto-align the RTPT to north, otherwise you’ll have to do so manually. But [Shubham Paul] has designed it so that even if you move the tracker about, the RTPT will readjust its calculations in real time. Each part of the project includes a wealth of related information beyond simple instructions to adequately equip any prospective builders.

This hack gets the job done. If it’s looks you’re after, an artistic expression of maker skills and astronomy can be seen in this planetary map that relies on persistence of vision.

Filed under: Arduino Hacks, software hacks

This little DIY 64×64 graphical printer by [Egor] is part pen plotter in design, somewhat dot matrix-ish in operation, and cleverly designed to use unmodified 9G servos. The project page is all in Russian (translation to English here) but has plenty of photos that make the operation and design clear. Although nearly the entire thing is made from laser-cut wood, [Egor] says that a laser cutter is optional equipment. The first version was entirely cut with hand tools.

screenshot-2016-12-06-10-49-13Small DIY CNC machines driven over a serial line commonly use Arduinos and CD-ROM drive guts (like this Foam Cutter or this Laser Paper Cutter) but this build uses its own custom rack-and-pinion system, and has some great little added details like the spring-loaded clip to hold paper onto the print pad.

The frame and parts (including all gears) are laser-cut from 4 mm plywood and the unit is driven by three small servos. A simple Java program processes images and an Arduino UNO handles the low-level control. A video of everything in action is embedded below.

Speaking of rack-and-pinion setups using cheap servos, that idea was taken to the next level by this design for a 3-D printed linear actuator that uses unmodified servos.

Filed under: Arduino Hacks, cnc hacks

Last time, I talked about how my storage situation and my cheap nature led me to build an RC joystick controller with a cell phone app and an ESP8266. The key to making this easy was to use the GUI builder called Blynk to make a user interface for an Android or Apple phone. Blynk can communicate with the ESP8266 and makes the project relatively simple.

ESP8266 and Arduino IDE

The ESP8266 Blynk code is straightforward. You do need to set up the Arduino IDE to build for the ESP8266. That can vary by board, but here’s the instructions for the board I was using (from Adafruit; see below).


Depending on the type of ESP8266 device you are using, you may need a 3.3 V serial cable or some other means of getting the firmware into the device. For the Adafruit device I had, it has a 5 V-tolerant serial connection so a standard USB to serial dongle plugs right in. There’s also two switches on my device. To get into bootload mode, you have to push the one button down, hold it, and then press the reset button. Once you release the reset button you can release the other button. The red LED half-glows and the device is then waiting for a download.

Otherwise, things are just like usual with the Arduino IDE. You do have to be aware of what objects are available on the ESP8266 as opposed to a regular Arduino. There are some subtle differences, too. For example, the EEPROM object has some extra methods because the ESP8266 emulates an EEPROM (more on that later).

Virtual Pins and Processing

If you are getting started, you can just make a simple user interface with a push button and wire it to an LED on the board. That’s the Blynk “hello world” program. But for the joystick there are a few other considerations.

Instead of wiring a widget to a physical pin, you can use a virtual pin. Your program can then read and write these virtual pins easily. A “pin” in this context could be a bit, a number, or even a string.

To handle a virtual pin write (for example, a button push or a slider changing value), you write a function using the BLYNK_WRITE macro. For example:

// Flip S1
if (!param.asInt()) return;

The framework will call this code when the associated virtual pin (V5) changes. One word of caution: a button press gets two calls; one for the press and one for the release. You need to test the value if you want to only act on one or the other. That’s why the first line tests for the parameter value of zero and returns, thus ignoring the button release.

In addition to asInt() you can convert the parameter to other types, including float (asFLoat), double (asDouble), and string (asStr).

The BLYNK_READ macro lets you provide code that will run with the framework wants to read a virtual pin (that is, send data from the embedded system back to the phone). You can also call Blynk.virtualWrite to immediately update the value of a virtual pin.

The Code

You can find the code on GitHub. It is quite straightforward: Two Servo objects control the pulse output. Their duration is set by virtual pins from Blynk. Because the joystick is set to output the microsecond count directly, there’s not much to that.

To make things more interesting, I arranged for buttons that could flip the X and Y axis and also reflect either axis (that is, invert the axis so instead of reading 1000-2000, it reads 2000-1000). Each of those is just a button push that calls a BLYNK_WRITE function. There’s a line of code that makes the buttons only operate on one of the two events you get from a button push and release.

Of course, once you can configure the joystick (including a recenter option), it is a pain to lose the configuration on each restart. So I decided to allow writing the configuration to EEPROM. That was the start of a lot of trouble.


The ESP8266 doesn’t have a true EEPROM. But the Arduino software emulates it with flash. When you want to use the EEPROM you have to inform the library how much memory you will use. It reads that memory from flash into a buffer. From that point on, all your EEPROM changes occur in the buffer. When you are done, you call end or commit and the library determines if you made changes. If you did, an entire flash page is erased and rewritten. If you call commit, you can make more changes (which then need to be written). If you call end, you are done.

By itself, that wouldn’t be a problem. However, watching the output on a scope, I noticed that when I would change configuration, sometimes–and only sometimes–the servo outputs would stall. The ESP8266 was still operating because the buttons that light LEDs would still work. I finally realized that any button that called for a EEPROM commit might hang the servo output. It wasn’t all the time, or even most of the time, but it was often enough to be annoying.

I tried a lot of things. Nothing completely fixed it. I finally resolved to have a “save” button so at least you know you might crash when you press it. Searching the Internet, this is a common problem. Since the simple code works, it seems as though the EEPROM code is disabling whatever timer interrupt the Servo object uses or not resetting the servo timer.

In the end, it mostly works, but any time you hit the save button, there’s a risk the servo output will die until the watchdog timer kicks in and resets the device.

Network Trickery

Of course, the ESP8266 has my local WiFi SSID and password plugged into it. You can set one up to act like a lot of modern devices where if it can’t connect it acts as its own access point so you can configure it. You could also just set it up as an AP and connect to it, assuming you can work out the Internet routing to get to the Blynk servers.

The problem is, I took the device into the office to show it off and realized that while my phone could connect to the corporate network, the ESP8266 wasn’t set up for it. I wasn’t carrying enough stuff to reprogram the device, but a solution dawned on me: I configured the hotspot on my phone to mimic the WiFi at home. With the same SSID and password, the joystick connected. Granted it was a little circuitous for the Blynk app to send data to the remote server, which sent it back to the phone which then routed it to the joystick, but it did work.

Final Analysis

Overall, using Blynk was pretty easy and worked pretty well. The EEPROM glitch didn’t seem to be a Blynk issue, so I can’t fault it for that. There were a few rough edges, though. For example, the LED buttons were inverted, but there was no simple way I could find to invert the operation of the buttons. That is, the buttons were on to send a high even thought that extinguishes the LEDs.

Using their server introduces some lag, but not nearly like I feared. If you have security concerns, you can run your own server, although I have not tried that. You still need “energy” for the app, though. I couldn’t decide how I felt about that. I understand that one has to make a living, and the joystick project fit in the free limits after all.

The other thing that would have been super would have been to be able to put the Blynk user interface in a browser. Blynk supports JavaScript, but as far as I can tell only as a remote platform, not as a host for the GUI. I understand that might cut into their revenue model, but it sure would be handy.

Speaking of which, you can field the Blynk embedded side into a lot of devices ranging from Arduinos, to MBed boards, to Raspberry PIs. You can connect via Ethernet, WiFi, Bluetooth, USB, and you can add your own connection methods.

This project didn’t even scratch the surface of the widgets you can use with Blynk. You can send e-mail, show video from a streaming server (like a web camera), or post to Twitter. There are gauges and sliders and lots of other things I didn’t need for the joystick.

If you don’t like Blynk, there are other options, although none of them struck me as quite as complete. For example, a quick scan of the Google Play Store shows quite a few similar apps. If you start weeding out the ones that won’t run on all the different platforms or work with Apple phones, you get a much shorter list. If you have experience–good or bad–with a different app, post in the comments.

Of course, you can always build your own phone app and communicate via standard networking. That’s actually not as hard as it sounds, but it isn’t as easy as using a tool like Blynk, either. Custom code can optimize what you are most worried about and will do exactly what you want. On the other hand, it would be a lot of work to support many different platforms, work on Google and Apple phones, and so on. For your application, though, that might not be as important as the control over the functions. That’s your call.


Filed under: Arduino Hacks, Featured, phone hacks

RC flying is one of those multi-disciplinary hobbies that really lets you expand your skill set. You don’t really need to know much to get started, but to get good you need to be part aeronautical engineer, part test pilot and part mechanic. But if you’re going to really go far you’ll also need to get good at electronics, which was part of the reason behind this Arduino servo tester.

[Peter Pokojny] decided to take the plunge into electronics to help him with the hobby, and he dove into the deep end. He built a servo tester and demonstrator based on an Arduino, and went the extra mile to give it a good UI and a bunch of functionality. The test program can cycle the servo under test through its full range of motion using any of a number of profiles — triangle, sine or square. The speed of the test cycle is selectable, and there’s even a mode to command the servo to a particular position manually. We’ll bet the build was quite a lesson for [Peter], and he ended up with a useful tool to boot.

Need to go even further back to basics than [Peter]? Then check out this primer on servos and this in-depth guide.

[via r/Arduino]

Filed under: Arduino Hacks, misc hacks

[Ryan Bates] loves arcade games, any arcade games. Which is why you can find claw machines, coin pushers, video games, and more on his website.

We’ve covered his work before with his Venduino project. We also really enjoyed his 3D printed arcade joystick based off the design of a commercial variant. His coin pushing machine could help some us finally live our dream of getting a big win out of the most insidious gambling machine at arcades meant for children.

Speaking of frustrating gambling machines for children, he also built his own claw machine. Nothing like enabling test mode and winning a fluffy teddy bear or an Arduino!

It’s quite a large site and there’s good content hidden in nooks and crannys, so explore. He also sells kits, but it’s well balanced against a lot of open source files if you’d like to do it yourself. If you’re wondering how he gets it all done, his energy drink review might provide a clue.

Filed under: Arduino Hacks, misc hacks, Raspberry Pi


Over the last couple of years, cat videos have become the undisputed champions of the web. Whether it’s kittens playing with their shadows to failed jump attempts to giving each another massages, we’re all guilty of watching a few of these clips from time to time (yes, even at work). Built with this in mind, oCat is a real-time tracker for feline-related activity on the Internet.

oCat consists of two parts: the oCat News Distractor and the Kitty o’Cat Twitter bot. Using Google’s YouTube API, the system works by continuously monitoring for new uploads, the number of new views each day, or a specific video that has received a remarkable amount of attention. It then tweets these stats and prints them out on thermal paper, stamping a paw print on the timeline for every 1,000 views.

Created by Annika Engelhardt, a digital media design master’s student at the University of the Arts in Bremen, oCat uses an Arduino along with an ESP Wi-Fi module, a servo, and an LCD screen. The aim of the project is to increase and reveal the amount of hours people spend watching cat videos online.

The cat is an altered Maneki-neko, holding a stamp using welding wire and hot glue. Even though I filled the stamp with extra ink, it did not work properly and I had to cut out the paw-shape from a sponge and glue it onto the original stamp.

The thermal printer used in the device needs a USB connection, so I used a Raspberry Pi to control it. I wrote a Python script that checks four different RSS news feeds for new posts every 15 minutes and prints one headline with a timestamp every minute.

The Twitter bot was programmed using Python and a library called tweepy. Most of the script is reading JSON files, juggling and comparing data and text files and in the end mixing up parts of a sentence to form a tweet. The bot will be enhanced in the future


Engelhardt exhibited the project at Galerie Flut in Bremen back in October. You can find more pictures and information on the project here.

  • 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