Posts with «attiny 85» label

Digging into an ATtiny Simulator Bug with GDB

Being able to track down a bug in a mountain of source code is a skill in its own right, and it’s a hard skill to learn from a book or online tutorial. Besides the trial-by-fire of learning while debugging your own project, the next best thing is to observe someone else’s process. [Uri Shaked] has given us a great opportunity to brush up on our debugging skills, as he demonstrates how to track down and squish a bug in the Wokwi Arduino simulator.

A user was kind enough to report the bug and include the offending Arduino sketch. [Uri]’s first step was to reduce the sketch to the smallest possible program that would still produce the bug.

Once a minimal program had been produced, it was time to check whether the problem was in one of the Arduino libraries or in the Wokwi simulator. [Uri] compiled the sketch, loaded it onto a ATtiny85, and compared the behavior of the simulator and the real thing. It turns out the code ran just fine on a physical ATtiny, so the problem must have been in the Arduino simulator itself.

To track down the bug in the simulator, [Uri] decided to break out the big gun—GDB. What follows is an excellent demonstration of how to use GDB to isolate a problem by examining the source code and using breakpoints and print statements. In the end, [Uri] managed to isolate the problem to a mis-placed bit in the simulation of the timer/counter interrupt flag register.

If you’d like to see more of [Uri]’s debugging prowess, check out his dive into an ATtiny’s write protection and configuration fuses. If you’ve been wowed by the power of GDB and want to learn more, check out this quick tutorial!

Hack a Day 27 Aug 06:01

Gravity-Defying Water Droplet Fountain Gets An Upgrade

When we last saw [isaac879]’s levitating RGB time fountain, it was made of wood which meant that it would absorb water and didn’t really show off the effect very well. His new version solves this problem with an acrylic case, new PCB and an updated circuit.

Like the original, this project drops water past strobing RGB LEDs creating an illusion of levitating, undulating colored water droplets. The pump at the top creates the droplets, but the timing has a tendency to drift over time. He thus implemented a PID controller to manage the pump’s drip rate, which was done by having the droplets pass by an infrared diode connected to an ATTiny85. The ’85 used the diode and PWM to control the pump motor speed and communicated to the Arduino over I2C.

The video shown below shows the whole process of designing and building the new time fountain. Everything from circuit and PCB design to 3D printing to assembly is shown along with narration describing what’s going on in case you want to build one yourself. If you do, all the files and components required are listed in the info section of the video.

There’s more that [isaac879] wants to do to improve the time fountain, but V2 looks great. It’s sleeker and smaller than the original and solves some of the design issues of the first. For more inspiration, check out some of the other levitating water fountain projects that have been posted over the years.