Posts with «arduino» label

2025 One Hertz Challenge: Estimating Pi With An Arduino Nano R4

Humanity pretty much has Pi figured out at this point. We’ve calculated it many times over and are confident about what it is down to many, many decimal places. However, if you fancy estimating it with some electronic assistance, you might find this project from [Roni Bandini] interesting.

[Roni] programmed an Arduino Nano R4 to estimate Pi using the Monte Carlo method. For this specific case, it involves drawing a circle inscribed inside a square. Points are then randomly scattered inside the square, and checked to see if they lie inside or outside the circle based on their position and distance of the circle’s outline from the center point of the square. By taking the ratio of the points inside the circle to the total number of points, you get an approximation of the ratio of the square and circle’s areas, which is equal to Pi/4. Thus, multiply the ratio by 4, and you’ve got your approximation of Pi.

[Roni] coded a program to run the Monte Carlo simulation on the Arduino Nano R4, taking advantage of the mathematical benefits of its onboard Floating Point Unit. It generates 100 new samples for the Monte Carlo approximation every second, improving the estimation of pi as it goes. It then displays the result on a 7-segment display, and beeps as it goes. [Roni] readily admits the project is a little too close in appearance to a classic Hollywood bomb.

We’ve seen some other neat Pi-calculating projects before, too.

A Repeater for WWVB

For those living in the continental US who, for whatever reason, don’t have access to an NTP server or a GPS device, the next best way to make sure the correct time is known is with the WWVB radio signal. Transmitting out of Colorado, the 60-bit 1 Hz signal reaches all 48 states in the low-frequency band and is a great way to get a clock within a few hundred nanoseconds of the official time. But in high noise situations, particularly on the coasts or in populated areas these radio-based clocks might miss some of the updates. To keep that from happening [Mike] built a repeater for this radio signal.

The repeater works by offloading most of the radio components to an Arduino. The microcontroller listens to the WWVB signal and re-transmits it at a lower power to the immediate area, in this case no further than a few inches away or enough to synchronize a few wristwatches. But it has a much better antenna for listening to WWVB so this eliminates the (admittedly uncommon) problem of [Mike]’s watches not synchronizing at least once per day. WWVB broadcasts a PWM signal which is easy for an Arduino to duplicate, but this one needed help from a DRV8833 amplifier to generate a meaningfully strong radio signal.

Although there have been other similar projects oriented around the WWVB signal, [Mike]’s goal for this was to improve the range of these projects so it could sync more than a single timekeeping device at a time as well as using parts which are more readily available and which have a higher ease of use. We’d say he’s done a pretty good job here, and his build instructions cover almost everything even the most beginner breadboarders would need to know to duplicate it on their own.

Hack a Day 07 Aug 21:00

Experience Other Planets with the Gravity Simulator

As Earthlings, most of us don’t spend a lot of extra time thinking about the gravity on our home planet. Instead, we go about our days only occasionally dropping things or tripping over furniture but largely attending to other matters of more consequence. When humans visit other worlds, though, there’s a lot more consideration of the gravity and its effects on how humans live and many different ways of training for going to places like the Moon or Mars. This gravity simulator, for example, lets anyone experience what it would be like to balance an object anywhere with different gravity from Earth’s.

The simulator itself largely consists of a row of about 60 NeoPixels, spread out in a line along a length of lightweight PVC pipe. They’re controlled by an Arduino Nano which has a built-in inertial measurement unit, allowing it to sense the angle the pipe is being held at as well as making determinations about its movement. A set of LEDs on the NeoPixel strip is illuminated, which simulates a ball being balanced on this pipe, and motion one way or the other will allow the ball to travel back and forth along its length. With the Earth gravity setting this is fairly intuitive but when the gravity simulation is turned up for heavier planets or turned down for lighter ones the experience changes dramatically. Most of the video explains the math behind determining the effects of a rolling ball in each of these environments, which is worth taking a look at on its own.

While the device obviously can’t change the mass or the force of gravity by pressing a button, it’s a unique way to experience and feel what a small part of existence on another world might be like. With enough budget available there are certainly other ways of providing training for other amounts of gravity like parabolic flights or buoyancy tanks, although one of the other more affordable ways of doing this for laypeople is this low-gravity acrobatic device.

Hack a Day 28 Jul 06:00

Project Scribe: Receipts for Life

Here’s a fun project. Over on their YouTube page [Urban Circles] introduces Project Scribe.

The idea behind this project is that you can print out little life “receipts”. Notes, jokes, thoughts, anecdotes, memories. These little paper mementos have a physical reality that goes beyond their informational content. You can cut them up, organize them, scribble on them, highlight them, stick them on the wall, or in a scrapbook. The whole idea of the project is to help you make easier and better decisions every day by nudging you in the direction of being more mindful of where you’ve been and where you’re going.

The project is well documented on its GitHub page. The heart of the project is a thermal printer. These are the things that print the receipts you get from the store. You may need to conduct some research to find the best thermal paper to use; there are some hints and tips on this topic in the documentation. In addition to the thermal printer is a pretty stand to hold it and an Arduino board to drive it. Firmware for the Arduino is provided which will serve a basic web interface via WiFi.

If you build one, we’d love to hear how it goes. If it doesn’t work out, you can always fall back to using the thermal printer to level up your Dungeons and Dragons game.

Thanks to [Brittany L] for writing in about this one.

Arduino Saves Heat Pump

For home HVAC systems, heat pumps seem to be the way of the future. When compared to electric heating they can be three to four times more efficient, and they don’t directly burn fossil fuels. They also have a leg up over standard air conditioning systems since they can provide both cooling and heating, and they can even be used on water heating systems. Their versatility seems unmatched, but it does come at a slight cost of complexity as [Janne] learned while trying to bring one back to life.

The heat pump here is a Samsung with some physical damage, as well as missing the indoor half of the system. Once the damage to the unit was repaired and refilled with refrigerant, [Janne] used an Optidrive E3 inverter controlled by an Arduino Mega to get the system functional since the original setup wouldn’t run the compressor without the indoor unit attached. The Arduino manages everything else on the system as well including all of the temperature sensors and fan motor control.

With everything up and running [Janne] connected the system to a swimming pool, which was able to heat the pool in about three hours using 60 kWh of energy. The system is surprisingly efficient especially compared to more traditional means of heating water, and repairing an old or damaged unit rather than buying a new one likely saves a significant amount of money as well. Heat pump projects are getting more common around here as well, and if you have one in your home take a look at this project which adds better climate control capabilities. to a wall mount unit.

Tune In to “Higher Lower”, the Minimal Handheld Electronic Game

[Tommy] has a great write-up about designing and building a minimalistic handheld electronic game called
“Higher Lower”. It’s an audio-driven game in which the unit plays two tones and asks the player to choose whether the second tone was higher in pitch, or lower. The game relies on 3D printed components and minimal electronics, limiting player input to two buttons and output to whatever a speaker stuck to an output pin from an ATtiny85 can generate.

Fastener-free enclosure means fewer parts, and on the inside are pots for volume and difficulty. We love the thoughtful little tabs that hold the rocker switch in place during assembly.

Gameplay may be straightforward, but working with so little raises a number of design challenges. How does one best communicate game state (and things like scoring) with audio tones only? What’s the optimal way to generate a random seed when the best source of meaningful, zero-extra-components entropy (timing of player input) happens after the game has already started? What’s the most efficient way to turn a clear glue stick into a bunch of identical little light pipes? [Tommy] goes into great detail for each of these, and more.

In addition to the hardware and enclosure design, [Tommy] has tried new things on the software end of things. He found that using tools intended to develop for the Arduboy DIY handheld console along with a hardware emulator made for a very tight feedback loop during development. Being able to work on the software side without actually needing the hardware and chip programmer at hand was also flexible and convenient.

We’ve seen [Tommy]’s work before about his synth kits, and as usual his observations and shared insights about bringing an idea from concept to kit-worthy product are absolutely worth a read.

You can find all the design files on the GitHub repository, but Higher Lower is also available as a reasonably-priced kit with great documentation suitable for anyone with an interest. Watch it in action in the video below.

Hack a Day 04 Jun 12:00

Look to the Sky With This Simple Plane Tracker

Do you ever get tired of stressing your neck looking for planes in the sky? Worry not! Here is a neat and cheap Arduino/Ras Pi project to keep your neck sore free! [BANK ANGLE] presents a wonderfully simple plane tracking system using an affordable camera and basic microcontrollers.

The bulk of the system relies on a cheap rotating security camera that gets dissected to reveal its internals. Here stepper control wires can be found and connected to the control boards required to allow an Arduino nano to tell the motors when and where to spin. Of course, the camera system doesn’t just look everywhere until it finds a plane, a Raspberry Pi takes in data from local ADS-B data to know where a nearby plane is.

After that, all that’s left is a nifty overlay to make the professional look. Combining all these creates a surprisingly capable system that gives information on the aircraft’s azimuth, elevation, and distance.

If you want to try your hand at making your own version of [BLANK ANGLE]’s tracker, check out his GitHub page. Of course, tracking planes gets boring after a while so why not try tracking something higher with this open-source star tracker?

Thank you Israel Brunini for the tip.

2025 Pet Hacks Contest: Feline Facial Recognition Foils Food Filching

Cats are no respecters of personal property, as [Joe Mattioni] learned when one of his cats, [Layla] needed a special prescription diet. Kitty didn’t care for it, and since the other cat, [Foxy]’s bowl was right there– well, you see where this is going. To keep [Layla] out of [Foxy]’s food and on the vet-approved diet, [Joe] built an automatic feeding system with feline facial recognition. As you do.

The hardware consists of a heavily modified feed bowl with a motorized lid that was originally operated by motion-detection, an old Android phone running a customized TensorFlow Lite model, and hardware to bridge them together. Bowl hardware has yet to be documented on [Joe]’s project page, aside from the hint that an Arduino (what else?) was involved, but the write up on feline facial recognition is fascinating.

See, when [Joe] started the project, there were no cat-identifying models available– but there were lots of human facial recognition models. Since humans and cats both have faces, [Joe] decided to use the MobileFaceNet model as a starting point, and just add extra training data in the form of 5000 furry feline faces. That ran into the hurdle that you can’t train a TFLite model, which MobileFaceNet is, so [Joe] reconstructed it as a Keras model using Google CoLab. Only then could the training occur, after which the modified model was translated back to TFLite for deployment on the Android phone as part of a bowl-controller app he wrote.

No one, [Joe] included, would say that this is the easiest, fastest, or possibly even most reliable solution– a cat smart enough not to show their face might sneak in after the authorized feline has their fill, taking advantage of a safety that won’t close a bowl on a kitty’s head, for example–but that’s what undeniably makes this a hack. It sounds like [Joe] had a great learning adventure putting this together, and the fact that it kept kitty on the proper diet is really just bonus.

Want to go on a learning adventure of your own? Click this finely-crafted link for all the details about this ongoing contest.

 

The Need For Speed?

We wrote up a video about speeding up Arduino code, specifically by avoiding DigitalWrite. Now, the fact that DigitalWrite is slow as dirt is long known. Indeed, a quick search pulls up a Hackaday article from 2010 demonstrating that it’s fifty times slower than toggling the pin directly using the native pin registers, but this is still one of those facts that gets periodically rediscovered from generation to generation. How can this be new again?

First off, sometimes you just don’t need the speed. When you’re just blinking LEDs on a human timescale, the general-purpose Arduino functions are good enough. I’ve written loads of useful firmware that fits this description. When the timing requirements aren’t tight, slow as dirt can be fast enough.

But eventually you’ll want to build a project where the old slow-speed pin toggling just won’t cut it. Maybe it’s a large LED matrix, or maybe it’s a motor-control application where the loop time really matters. Or maybe it’s driving something like audio or video that just needs more bits per second. One way out is clever coding, maybe falling back to assembly language primitives, but I would claim that the right way is almost always to use the hardware peripherals that the chipmakers gave you.

For instance, in the end of the video linked above, the hacker wants to drive a large shift register string that’s lighting up an LED matrix. That’s exactly what SPI is for, and coming to this realization makes the project work with timing to spare, and in just a few lines of code. That is the way.

Which brings me to the double-edged sword that the Arduino’s abstraction creates. By abstracting away the chips’ hardware peripherals, it makes code more portable and certainly more accessible to beginners, who don’t want to learn about SPI and I2C and I2S and DMA just yet. But by hiding the inner workings of the chips in “user friendly” libraries, it blinds new users to the useful applications of these same hardware peripherals that clever chip-design engineers have poured their sweat and brains into making do just exactly what we need.

This isn’t really meant to be a rant against Arduino, though. Everyone has to start somewhere, and the abstractions are great for getting your feet wet. And because everything’s open source anyway, nothing stops you from digging deeper into the datasheet. You just have to know that you need to. And that’s why we write up videos like this every five years or so, to show the next crop of new hackers that there’s a lot to gain underneath the abstractions.

This article is part of the Hackaday.com newsletter, delivered every seven days for each of the last 200+ weeks. It also includes our favorite articles from the last seven days that you can see on the web version of the newsletter. Want this type of article to hit your inbox every Friday morning? You should sign up!

The Mouse Language, Running on Arduino

Although plenty of us have our preferred language for coding, whether it’s C for its hardware access, Python for its usability, or Fortran for its mathematic prowess, not every language is specifically built for problem solving of a particular nature. Some are built as thought experiments or challenges, like Whitespace or Chicken but aren’t used for serious programming. There are a few languages that fit in the gray area between these regions, and one example of this is the language MOUSE which can now be run on an Arduino.

Although MOUSE was originally meant to be a minimalist language for computers of the late 70s and early 80s with limited memory (even for the era), its syntax looks more like a more modern esoteric language, and indeed it arguably would take a Python developer a bit of time to get used to it in a similar way. It’s stack-based, for a start, and also uses Reverse Polish notation for performing operations. The major difference though is that programs process single letters at a time, with each letter corresponding to a specific instruction. There have been some changes in the computing world since the 80s, though, so [Ivan]’s version of MOUSE includes a few changes that make it slightly different than the original language, but in the end he fits an interpreter, a line editor, graphics primitives, and peripheral drivers into just 2KB of SRAM and 32KB Flash so it can run on an ATmega328P.

There are some other features here as well, including support for PS/2 devices, video output, and the ability to save programs to the internal EEPROM. It’s an impressive setup for a language that doesn’t get much attention at all, but certainly one that threads the needle between usefulness and interesting in its own right. Of course if a language where “Hello world” is human-readable is not esoteric enough, there are others that may offer more of a challenge.