Close

Getting started with ATTiny84A on PlatformIO

A project log for urban-edc-flashlight

Multifunction flash light for everyday carry

christoph-tackChristoph Tack 01/04/2022 at 19:260 Comments

Tools

PlatformIO setup

  1. Create a new project and select "Generic ATtiny84 (Atmel)".  The Arduino-framework will automatically be selected.
  2. Adjust the platformio.ini file:
    [env:attiny84]
    platform = atmelavr
    board = attiny84
    framework = arduino
    upload_protocol = avrispmkII
    upload_port = usb
    
    ; https://www.engbedded.com/fusecalc/
    board_build.f_cpu = 1000000L
    board_fuses.lfuse = 0x62
    board_fuses.hfuse = 0xD7
    board_fuses.efuse = 0xFF
    upload_flags =
        -B  ; bit clock needs to be slowed down (original=1) when underclocking the MCU
        10
    
    lib_deps =
        stevemarple/AsyncDelay @ ^1.1.2
        thomasfredericks/Bounce2 @ ^2.70
    
    ; FTDI TTL-232R-3V3-WE
    monitor_port = /dev/ttyUSB0
    monitor_speed = 4800
  3. Simply hit the "Upload"-button to program your device.

That's it.  No makefiles, no menu configs.

Remember to upload your code again after programming the fuses (if needed).

Here goes the blinkenlight example:

LED_BUILTIN = PIN_PB2

#include <Arduino.h>

void setup()
{
    // put your setup code here, to run once:
    pinMode(PIN_PB0, OUTPUT);
}

void loop()
{
    // put your main code here, to run repeatedly:
    digitalWrite(PIN_PB0, HIGH);
    delay(500);
    digitalWrite(PIN_PB0, LOW);
    delay(500);
}

framework-arduino-avr-attiny

More info about the framework (and the pin numbering) can be found on:

Discussions