How to use the Digispark with micronucleus bootloader in the Arduino IDE
The Digispark USB development board is a compact board with the ATtiny85 AVR microcontroller. You can use it in the Arduino IDE by adding http://digistump.com/package_digistump_index.json as an additional board support URL in File / Preferences next to Additional Boards Manager URLs.
After this, open the menu Tools / Board / Boards Manager... and install the package Digistump AVR Boards:
The Digispark is now supported, but the board support package installs an older version of the command-line tool micronucleus
for the bootloader. This is incompatible with newer versions of the bootloader. If you've upgraded the micronucleus bootloader on your Digispark, you need to upgrade the command-line tool too.
So make a backup of the original file and copy the newer micronucleus
binary that you installed earlier:
cd ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/ mv micronucleus micronucleus.original cp /usr/local/bin/micronucleus .
Now you can flash your Arduino sketches to the device. Try it with one of the example sketches, such as the one in File / Examples / Digispark_Examples / Start. This has the following code that blinks the Digispark's LED:
// the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(0, OUTPUT); //LED on Model B pinMode(1, OUTPUT); //LED on Model A or Pro } // the loop routine runs over and over again forever: void loop() { digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(1, HIGH); delay(1000); // wait for a second digitalWrite(0, LOW); // turn the LED off by making the voltage LOW digitalWrite(1, LOW); delay(1000); // wait for a second }
Then choose the board Digispark (Default - 16.5mhz) in the menu Tools / Board / Digistump AVR Boards and compile the code. If you click on the upload button after this, the Arduino IDE asks you to put the Digispark in a USB port. If all goes well, it uploads the firmware to your board with the newer version of the micronucleus
command. And finally the LED on the board starts blinking.