The ATtiny is a small, inexpensive chip that can replace the Arduino in a project you have prototyped. This helps make the project smaller and more permanent, as well as freeing up the Arduino for more fun!
The chip comes in a few different types – ones with more flash memory, lower power, and so forth. The ATtiny is great if you want to program a bunch of chips in a row, put them in your circuits, and forget about them.
If you're soldering together an ATtiny-based project, use a socket instead of soldering directly to the chip. This protects the IC from the high temperature, and you'll be able to remove and reprogram it later.
If you want to go this route, check out Arjun's fantastic tutorial.
What I've found most useful is the Digispark breakout board. It's the best of both worlds – a hybrid of the ATtiny's size and price with the convenience of programming it directly from your computer. You can take the other Arduino out of the picture completely! There are two main versions: one with a direct plug for your computer (or a USB power bank), and one with a USB Micro jack.
With a Digispark, you can solder straight to the breakout pins. I attached female headers to the board so that I could easily swap it in and out of NeoPixel circuits. But for the simple Blink sketch, here's all you need:
We'll start with the Blink example sketch (File > Examples > 01.Basics > Blink). Change each instance of pin
, to match your setup.
To program the board, first we need to open up the Arduino IDE's Preferences pane. Under "Additional Boards Manager URLs", enter this URL (after any you already have):
(Didn't work? Check the official page for updates, and let me know!)
This tells the IDE how to talk to your Digispark, and you only have to do it once. Now, go to Tools > Board > Boards Manager, find the Digistump list item, click on it, and hit the Install button. After this has completed, you'll need to restart the IDE.
Assuming you went with the regular board, pick Digispark (Default - 16.5mhz) from the Boards menu. Don't even worry about the port! You're going to hit Upload first, then plug the board into a USB port, when the output window asks you to. This thing programs pretty fast, so you'll be done in a flash :)
You can also hook it up to NeoPixels and control them! It's a fantastic solution for a shortish string of lights. I tried running about 120 NeoPixels off one Digispark, and it got a bit hot due to the onboard voltage regulator, so maybe keep it on the lower side (or use a plain ATtiny85).
Here's the circuit:
I had already soldered male headers to the end of my NeoPixel strips, so I soldered a matching female header to my Digispark so I could easily swap it between projects. Pure magic!
Some example code is attached below. I switched to pin 1 for this (P0, P1, and P4 are all capable of PWM, as the NeoPixels require). Have fun!