The Digistump Digispark is a tiny, simple, and cheap development board using the ATtiny85 MCU. While the official version is no longer for sale, clones are easily found online for around $2 each.
already supports the
ATtiny85 on the Adafruit Trinket
The Trinket is nearly identical to the Digispark, but with a different USB
cargo run support won’t work. Instead, you’ll need
to convert the output binary and deploy it with the
micronucleus CLI tool.
Download the latest Micronucleus CLI for your platform.
binutils for AVR
sudo apt install binutils-avr
brew tap osx-cross/avr && brew install avr-binutils
Build and Deploy a simple PWM demo#
git clone https://github.com/Rahix/avr-hal
avr-objcopy --output-target=ihex ../../target/avr-attiny85/debug/trinket-simple-pwm.elf ../../target/avr-attiny85/debug/trinket-simple-pwm.hex
micronucleus --timeout 60 --run --no-ansi ../../target/avr-attiny85/debug/trinket-simple-pwm.hex
- Plug in your Digispark. Once the application is uploaded, the LED will start pulsing.
I’ve found that the Rust PWM example compiles to a much larger binary than the equivalent C code using Arduino libraries. (1265 bytes in Rust vs 888 bytes in C). I’m new to embedded Rust, so please let me know in the comments if you have any tips or resources for getting the size down.