Skip to content

ATTiny412

ATTiny 412 Datasheet

The ATtiny412 is an 8‑pin tinyAVR 1‑series microcontroller from Microchip with up to 4 KB flash, 256 B SRAM, and a CPU capable of running up to 20 MHz, designed for low‑power operation. Its compact package and modern peripherals (Event System, SleepWalking, and enhanced analog features) make it well suited for small, energy‑efficient embedded applications

By far the hardest part of programming the ATTiny is setting up the programmer, which is, in my case, an Arduino Uno.

Step 1, like always, is finding a suitable tutorial. I used this one:

While outdated, it provides the correct workflow. First, I went to this repo and downloaded the .zip file. After extracting, I went to 'jtag2updi-master\jtag2updi-master\source', then I copied EACH file in that "source" folder INTO the folder at the bottom of the "source" file. Inside of that folder, I double clicked the 'jtag2updi.ino' file to open it in Arduino IDE. You should see this:

Yes, there are supposed to be that many tabs open.

If you watched the tutorial and maybe skipped ahead, you may notice that you are supposed to connect the reset pin to the ground pin with a 10uf capacitor to prevent the atuo-reset function before every upload- at this step, DO NOT DO THAT!

Once you connect your arduino to the IDE, simply run the sketch. Then, connect the Arduino to the ATTiny using this diagram: And the ATTiny pinouts: A little summary:

Arduino GND --> ATTiny GND

Arduino 5V --> ATTiny VCC

Arduino D6 --> 4.7 k Ohm Resistor *--> ATTiny Pin 6

Arduino RESET --> 10uf Capacitor --> Arduino GND (long leg in reset)(AFTER you flash the jtag2updi firmware)

(*)- In my case, I only had access to a 10k Ohm resistor, which worked fine. After this, you are ready to code your chip.

First, you have to visit this repo and set up the board manager url and library. From that repo, I took this link:

http://drazzy.com/package_drazzy.com_index.json
and copied it into the board manager menu (CTRL + Comma). Then, I went to the "Boards Manager" menu on the right, then searched for "megaTinyCore" and installed the package

Next, go to the tools menu, and change your board to the option that contains "ATTiny 412" (it will have several other boards). Then, at the bottom, change the "Programmer" option to 'jtag2updi', like this:

Now, you can write a simple script like this:

And then upload it(You MUST upload it via the sketch --> Upload to Programmer), like this:

And here is the code working:

You may notice the 'avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description' error. It is harmless, according to this forum post. It took me a second to realize that, as I thought something was broken, but I just used the wrong pins in my code. This error does not affect pin outputs, and if your code does not work, that is a you problem.