Tiny Function Generator on the ATtiny85, Complete with OLED

It’s easy to have a soft spot for “mini” yet perfectly functional versions of electronic workbench tools, like [David Johnson-Davies]’s Tiny Function Generator which uses an ATtiny85 to generate different waveforms at up to 5 kHz. It’s complete with a small OLED display to show the waveform and frequency selected. One of the reasons projects like this are great is not only because they tend to show off some software, but because they are great examples of the kind of fantastic possibilities that are open to anyone who wants to develop an idea. For example, it wasn’t all that long ago that OLEDs were exotic beasts. Today, they’re available off the shelf with simple interfaces and sample code.

The Tiny Function Generator uses a method called DDS (Direct Digital Synthesis) on an ATtiny85 microcontroller, which [David] wrote up in an earlier post of his about waveform generation on an ATtiny85. With a few extra components like a rotary encoder and OLED display, the Tiny Function Generator fits on a small breadboard. He goes into detail regarding the waveform generation as well as making big text on the small OLED and reading the rotary encoder reliably. His schematic and source code are both available from his site.

Small but functional microcontroller-based electronic equipment are nifty projects, and other examples include the xprotolab and the AVR-based Transistor Tester (which as a project has evolved into a general purpose part identifier.)

Continuity Tester uses the ATtiny85’s Comparator

There’s an inside joke among cyclists – the number of bikes you need is “n+1”, where “n” is your current number of bikes. The same probably also applies to the number of tools and equipment a hacker needs on their workbench. Enough is never enough. Although [David Johnson-Davies] has a couple of multimeters lying around, he still felt the urge to build a stand-alone continuity tester and has posted details for a super-simple ATtiny85 based Continuity Tester on his blog. For a device this simple, he set himself some tall design goals. Using the ATtiny85 and a few SMD discretes, he built a handy tester that met all of his requirements and then some.

The ATtiny85’s Analog Comparator function is perfectly suited for such a tester. One input of the comparator is biased such that there is a 51 ohm resistor between the input and ground. The output of the comparator toggles when the resistance between the other input and ground is either higher or lower than 51 ohms. Enabling internal pullup resistors in the ATtiny85 not only takes care of proper biasing of the comparator pins, but also helps reduce current consumption when the ATtiny85 is put to sleep. The test current is limited to 100 μA, making the tester suitable for use in sensitive electronics. And enabling the sleep function after 60 seconds of inactivity reduces standby current to just about 1 μA, so there is no need for a power switch. [David] reckons the CR927 button cell ought to last pretty long.

For those interested in building this handy tester, [David] has shared the Eagle CAD files as well as the ATtiny85 code on his Github repository or you could just order out some boards from OSHpark.

Ambitious ATtiny85 Board Tests a Beginner’s Skills

[Chris O’Riley] has been playing around with Arduinos for around a year, and decided he wanted a breadboardable ATtiny85 in order to prototype using the actual controller that would be used in the final project. He wants to use it to interface with a Bosch BMP280 pressure sensor, but for now it stands alone.

It’s a simple board with the Tiny85, 3.3 V and 5 V regulators, a power LED, as well as the usual resistors and caps [Ed: not resistor sand caps]. The double-sided PCB [Chris] milled himself — he’s an illustrator and photographer by day, so it’s no surprise the board turned out gorgeous. He designed the board in Illustrator after taking a stab at Eagle, then ran it through his CNC to mill the circuits using a .017 inch end mill as well as drilling the vias. He add solder paste using the tip of a knife, but after messing around with an iron, he ended up investing in a hot air rework station.

We love our Tiny85s here on Hackaday. Check out the ATtiny85 gaming console, the NTSC-generating ATTiny85, and making DIY I2C devices with the chip.

Saturday Clock: An 0.000011574Hz ATtiny85 clock

In these times when we try to squeeze out extra clock cycles by adding more cores to our CPUs and by enlisting the aid of GPUs, [Ido Gendel] thought it would be fun to go in the exact opposite direction, supply a clock to the ATtiny85 that cycles only once per day, or at 0.000011574Hz. What application could this have? Well, if he could do it in seven instructions or less, how about turning on an LED at sunset Friday evening, to indicate the start of the Jewish Shabbat (Saturday), and turn it off again at sunset Saturday evening.

Notice the subtlety. A clock that cycles once per day means you can execute at most one instruction per day. Luckily on AVR microcontrollers, the instructions he needed can execute in just one cycle. That of course meant diving down into assembly code. [Ido] wasn’t an assembly wizard, so to find the instructions, he compiled C code and examined the resulting assembly until he found what he needed. One instruction turns on the LED and the instruction immediately following turns it off again, which normally would make it happen too fast for the human eye to register. But the instruction to turn it on runs on Friday evening and the very next instruction, the one that turns it off, doesn’t run until Saturday evening. Do you feel like you’re in a science fiction story watching time slowed down? Freaky. A few NOPs and the jump for the loop take up the remaining five cycles for the week.

For the source of the clock he chose to use an LDR to detect when the light level dropped at the end of the day. The problem he immediately ran into was that clouds, bird shadows, and so on, also cause drops in the light level. The solution he found was to widen the light and dark range by adding a TLV3702 push-pull output comparator and some resistors. [Ido] gives a detailed explanation of the circuit in the video after the break.

Continue reading “Saturday Clock: An 0.000011574Hz ATtiny85 clock”

Making a Spectrum Analyzer the Wrong Way on an ATtiny85

Everyone’s a critic, but it’s hard to argue with success. And that’s exactly what [agp.cooper] has with his ATtiny85-based spectrum analyzer devices.

The “normal” way to build a spectrum analyzer is to collect a bunch of samples and run a Fast Fourier Transform (FFT) on them all in one shot. As the name implies, the FFT is fast, and the result is the frequency components of the sampled data. [agp.cooper]’s “wrong” way to do it takes the Goertzel algorithm, which is used for detecting the intensity of a particular frequency, and scanning across the frequency range of interest. It’s a lot slower than a single FFT but, importantly for the ATtiny85 that he implements this on, it’s less demanding of the RAM.

Continue reading “Making a Spectrum Analyzer the Wrong Way on an ATtiny85”

DIY I2C Devices with ATtiny85

[Pawel] has a weather station, and its nerve-center is a Raspberry Pi. He wanted to include a light sensor but the problem is, the Pi doesn’t have a built-in ADC to read the voltage off the light-dependent resistor that he (presumably) had in his junk box. You can, of course, buy I2C ADC chips and modules, but when you’ve already got a microcontroller that has ADC peripherals on board, why bother?

[Pawel] wired up a tremendously simple circuit, downloaded some I2C slave-mode code, and added an LED for good measure. It’s all up on GitHub if you’re interested.

Bright by Day, Dark by Night!

We’re covering this because we rarely see people coding for I2C slave devices. Everyone and their mom uses I2C to connect to sensors, for which the Arduino “Wire” library or “i2c-tools” on the Pi do just fine. But what do you do when you want to make the I2C device? [Pawel]’s project makes use of TinyWireS, a slave-mode SPI and I2C library for AVR ATtiny Arduino projects.

Here, [Pawel] just wanted a light sensor. But if you’re building your own devices, the sky is the limit. What’s the most esoteric I2C sensor that you can imagine? (And is it really the case that we haven’t seen an I2C slave device hack since 2010?)

Tiny ATtiny85 Game Console

[Ilya Titov] has made a game console. Not just any game console, but an extremely small ATtiny85-based console suitable for putting on a key ring and assembled into a very professional product with PCB and 3D printed case. This is a project that has been on the go since 2014, but the most recent update is a new version designed for tighter and more easy assembly.

All construction is through-hole rather than SMD, and aside from the ATtiny85 the console uses an OLED screen, piezo buzzer, tactile switches and a handful of passive components. Power comes from a single CR2032 coin cell which sits under the screen. Best of all the PCB design is available as a PDF and the 3D printed case can be found on Thingiverse.

There are two games for the console, as well as the Breakout clone whose code is in the 2014 piece linked above he’s written UFO Escape, an obstacle-avoiding side-scroller. You’ll have to burn both game and 8MHz internal clock bootloader to the ATtiny85 yourself. There are no cartridges with this console, though if the processor sits in a DIP socket the game can be changed over simply by swapping processors programmed with the appropriate game.

He’s produced a full assembly video with some UFO Escape gameplay thrown in, shown here below the break.

Continue reading “Tiny ATtiny85 Game Console”