This is an example project for PlatformIO to build the canonical blink code for the Digispark USB development board with an Atmel AVR ATtiny85 microcontroller.
Note
This doesn't use the Arduino framework, but directly uses the native AVR registers.
You can use this project as a template to build your own AVR code for the Digispark with PlatformIO.
You need PlatformIO and the Atmel AVR platform in PlatformIO. You can install both with:
pip3 install platformio
pio platform install atmelavr
The Digispark runs the Micronucleus bootloader. If you've bought it recently, the bootloader is a recent version that isn't supported by PlatformIO's older micronucleus
command. Therefore, you need to build the newer version of the command. On Ubuntu or Debian this goes like this:
git clone https://github.com/micronucleus/micronucleus.git
cd micronucleus/commandline
sudo apt install libusb-dev
make
sudo make install
The platformio.ini file in this example project defines a custom command to refer to the micronucleus
command you've built.
Build the code with:
pio run
Build and upload the code to the Digispark with:
pio run -t upload
Plug in the device into a USB port of your computer when asked.
If you want to use this project as a template for your own projects, have a look at the GitHub Action file. It automatically builds the code on each push and pull request and checks for errors and warnings. There's also a Makefile to make checking and building code easier.
This project is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE file for more information.