This is a page that serves as a signpost for experiments with a smaller version of Arduino. ATtiny85 has 8K of flash memory, 512 SRAM and 512 EEPROM. It may seem a little, but even in such a small memory you can get a pretty big program. ATtiny85 is my favorite microcontroller and only in exceptional situations I replace it with ATtiny84 microcontroller, which has more pins and a bit better peripherals.
The main reason is the price. You can buy the microcontroller for the Euro, and when something happens, nothing happens. In addition, it is simple to made circuitry that is robust, can be connected to a higher voltage (using a voltage regulator) and you can easily control other circuits with the digital pins.
How to program ATtiny85 using the Arduino can be found in a separate article Arduino as an ISP programmer. There is also the second option that you can lay down a development board and program it using USBasp.
In order for the microcontroller to be programmed, support must be installed in the Arduino IDE. The procedure applies to IDE 1.6.4 and above:
The previous core is good for the basic programming of ATtiny85. However, if you want to use more options of the microcontroller, it is advisable to look for more redesigned cores. They support the changing of many parameters. For example, changing fuse settings, different clock sources, and code optimization during the translation.
Five digital pins are available in the default settings. It is possible to switch the microcontroller to the state when it uses the last pin instead of the reset, but it is a one-time issue and it is no longer possible to program it using the Arduino. That is why we will not even take this option into account. The individual pins are controlled as follows:
There are three pins available:
There are three inputs available:
There is a fourth analog pin, but it is on the same pin as RESET and its use is not easy.
ADC conversions provide more choices and those are examined in a separate article of the ADC.
Working with EEPROM works just like in the usual Arduino. If you want to make programming easy, find the inspiration in the article on the practical use of EEPROM.
If there are no serious reasons for this, leave the microcontroller at the 1 MHz factory setting. If the speed is important, it can be switched to 8 MHz and in the case of extra speed requirements it is possible to go up to 20 MHz but only at the cost of pins 3 and 4. Speed setting is described in the article Arduino as an ISP programmer.
The information on the occupation of pins 3 and 4 is not entirely correct. There is a possibility to switch ATtiny85 into a mode that even at higher speed uses an internal oscillator. It is called PLL and can be used to achieve higher speeds. The easiest way to do this is to use the core ATTinyCore and set it in the menu. Be sure to use the menu item Burn bootloader.
Again what is in the previous paragraph. To add work, you can program it with low-level functions. But at ATtiny85 we have 8 kB of memory available, and it's enough for regular size programs. That's why it's much more convenient to write digitalWrite than to worry about bitwise port operations.
Only when it comes to speed or more significant memory savings, optimization techniques are needed. The old programmer's rule is that the customer does not really care how many years you've spent the program for flashing the LED. When it works, the customer will never see your source code.
List of projects with ATtiny85. If you want to program the microcontroller more, it's a good idea to build a development board. In projects, you can find the boards in the DIP design and the boards with SMD components. The LED strip dimmer was my pilot project I was learning. But surprisingly, this model of dimmer uses about 10 of my friends on my boards and an unknown number of hobbyists who have been inspired with this project.
List of articles about ATtiny85. I wrote many articles about this microcontroller, so I tried to divide them into logical groups.
On these pages I never wrote about Arduino directly for beginners. The reason was that there are enough examples of Arduino on the Internet that will teach you the basics of programming. With the ATtiny85 microcontroller it's different. Examples are few and difficult to find examples that would be simple enough. I'm trying to do this in this series and describe the topics and examples I do so that after reading a series of these articles a less experienced user could program these small microcontrollers.
Different ways of programming a microcontroller.
Other articles that could not be categorized.