This is an old revision of the document!
The bootloader is the code that is pre-programmed on your Digispark and allows it to act as a USB device so that it can be programmed by the Arduino IDE.
The Digispark runs the “micronucleus tiny85” bootloader version 1.02, an open source project: https://github.com/micronucleus/micronucleus originally written by Bluebie: https://github.com/Bluebie.
CAUTION We are not at this point supporting upgrading the firmware, so if you decide to, you do so entirely at your own risk.
NOTE: If you used a version of the ide where the digistump add-ons were installed separately you must delete the digistump folder at My Documents/Arduino/hardware (windows) or Documents/Arduino/hardware (OS X) or /home/[username]/Sketchbook (Linux) or this new IDE install will not work properly and you will get library errors!
The Digispark uses the Arduino IDE - Digistump Release 1.5.x which is the Arduino IDE with some custom additions and supports Digispark, Digispark Pro, and DigiX. These are presented as a fully integrated package with 1.5.x that can be downloaded as an installed or zip file.
First download the appropriate package:
Compiling from source: https://github.com/digistump/DigistumpArduino
The Digispark works a bit differently than some Arduino compatible products. Not only is there a special add-on to the IDE to support it, but it also programs with a different procedure.
From the Tools menu select Board→Digispark (Default - 16.5Mhz)
(The Tools→Programmer selection does not matter)
Write some code, open your code, or open a Digispark example.
You do not need to plug in your Digispark before invoking upload
Hit the upload button. The bottom status box will now ask you to plug in your Digispark - at this point you need to plug it in - or unplug and replug it.
You'll see the upload progress and then it will immediately run your code on the Digispark.
If you unplug the Digispark and plug it back in or attach it to another power source there will be a delay of 5 seconds before the code you programmed will run. This 5 second delay is the Digispark Pro checking to see if you are trying to program it.
If you're just getting started try the above procedure with the example you can find by going to File→Examples→Digispark→Start
Here is the code it will load:
// 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 } // 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 }
This code will blink the BUILTIN LED (on either pin 0 or pin 1 depending on the Digispark model see:Model Identification).
As soon as it has uploaded you should see the LED start to blink!
For some sample code for the basic I/O function see here: Digispark Basics
The Arduino Environment introduction is a great start if you are new to the Arduino IDE: http://arduino.cc/en/Guide/Environment
The Digispark supports all features found in the IDE with the exception of the serial monitor and the burn bootloader functionality.
Many existing libraries will not work with the Digispark: For I2C devices check out the TinyWireM library, which makes it super simple to port an I2C based device library over to use with the Digispark.
Pin outs:
For a handy pin reference flip over the Digispark - pin capabilities are listed on the back
For some sample code for the basic i/o function see here: Digispark Basics
The Digispark, due to its small size and low cost is not as robust as a full blown Arduino.
When testing a new circuit we recommend that you test it with an external power supply first. Connecting a shorted circuit to the Digispark and connecting it to your computer could damage your computer and/or its USB ports. We take no responsibility for damage to your machine as a result of the use of a Digispark.
We strongly recommend connecting your Digispark through a USB hub which will often limit the damage caused by a short circuit to the usb hub. For the record, we've found many computers have usb fuses built in, and when we blew them on our 27“ Mac monitor, thankfully they reset and everything worked after a power down.
The Digispark does not have short circuit or reverse polarity protection. Connecting power to the Digispark power pins backwards will almost certainly destroy it.
The Digispark is small enough to present a choking hazard and small enough to be inserted into some sockets. We take no responsibility for misuse of the product. Please treat electricity and electronics with respect and common sense.
The Digispark pushes affordable, small components to their limits by using software to emulate USB functions generally served by a dedicated chip. For this reason much of the Digispark's USB operation is considered borderline out of spec. Certain laptops, older machines, and just some cheaply made USB hubs/controllers do not like this. We tested and designed the Digispark for maximum compatibility but we can not guarantee it will work with everything.
In addition remember the Digispark only shows up as a programmable device for 5 seconds, after that it will start running its code (when it is new and un-programmed this means it will blink) and disappear or act like the USB device you programmed it to act like.
Always remember to unplug the Digispark before hitting upload and plug it in when the Arduino IDE requests you to. If you get an error that assertion failed or micronucleus crashed during upload then you probably did not unplug your Digispark before uploading.
If the computer will not recognize the Digispark try the following:
If it won't upload:
Did you set your board AND programmer to Digispark in the Arduino IDE?
WINDOWS:
MAC
LINUX: See the Linux troubleshooting page
If your upload fails in the middle of it, you may also be using a bad USB cord and or a bad hub.
Support requests are best posted to the forum, so everyone can benefit and we can help each other through any issues - http://digistump.com/board