The DigiSpark is small and inexpensive. To keep it that way it has limited features. One feature that Arduino programmers may miss is the serial monitor window. On the Arduino this is used to send and receive information from the Arduino.
Although the DigiSpark does not support the serial monitor window there are several options available with similar features.
Also see the DigiKeyboard Wiki Page
There is also a RubyGem for communication using the DigiUSB Library
The rubygem is a package install-able using the rubygem package manager. You can download the files from github but you also need to use gem tools to compile it in to a gem and install it.
To install the rubygem, make sure you have libusb 1.x and ruby 1.9.x or ruby 2.0 installed (mac's and many versions of linux come with 1.8 installed, which is no good for this), then open a terminal and run 'gem install digiusb'. You might need to sudo that depending on your platform. Finally, you aught to be able to just type 'digiterm' in your terminal window and it will find the most recently attached digispark, connect to it, and start outputting everything printed via DigiUSB on the device and forwarding keystrokes from the terminal window in to the digispark.
Because of all this complex inter-dependency it might not be a good option for beginners.
The onboard LED and the I2C LCD can also be good debugging options.
If you didn't plan to use DigiUSB in your final sketch, the following proposed alternative consumes less pin and program memory than USB.
Since the last version of <SoftSerial> library (may 2013), <SoftSerial> is an alternative for debugging Digispark just using a single I/O.
By declaring a <SoftSerial> object with the same pin for Tx and Rx: it's possible to use a half duplex (request/response) software serial port using a single I/O.
The external interface is composed of 2 resistors and a regular diode (See below).
This approach allows to use the built-in Serial Monitor of the arduino IDE.
Please, note this solution requires a native RS232 port (rare today) or a RS232/USB adapter on the development PC.
In your sketch, declare a <SoftSerial> object with the same pin for Tx and Rx as depicted below:
#include <TinyPinChange.h> #include <SoftSerial.h> #define DEBUG_TX_RX_PIN 2 //Adjust here your Tx/Rx debug pin SoftSerial MyDbgSerial(DEBUG_TX_RX_PIN, DEBUG_TX_RX_PIN, true); //true allows to connect to a regular RS232 without RS232 line driver void setup() { MyDbgSerial.begin(38400); //After MyDbgSerial.begin(), the serial port is in rxMode by default MyDbgSerial.txMode(); //Before sending a message, switch to txMode MyDbgSerial.println(F("\nDebug enabled")); MyDbgSerial.rxMode(); //switch to rxMode to be ready to receive some commands } void loop() { if(MyDbgSerial.available()) { MyDbgSerial.txMode(); MyDbgSerial.print(F("\nReceived: "));MyDbgSerial.write(MyDbgSerial.read());MyDbgSerial.print(F("\n")); MyDbgSerial.rxMode(); } }
SERIAL SINGLE I/O DEBUGGING CABLE ___________________/\__________________ / \ ____ .--------. | \ | GND |--------------------------------+---o5 \ | | 47K | | 9o | | | .--###--' | o4 | | DEBUG | 4.7K | | 8o | | TX_RX |-------------------###--+--|<|------o3 | ---> To regular RS232 SubD 9 pins Male of PC | PIN | ^ | 1N4148 | 7o | or to RS232/USB adapter | | | '-----------o2 | '--------' | | 6o | ATtiny85 Single | o1 / (Digispark) I/O |____/ SubD 9 pins Female
Plug the “Serial Single I/O Debugging Cable ” to a native RS232 port or to a RS232/USB adapter on your development PC.
With this approach, the regular serial monitor of the arduino IDE can be used. In the IDE, just select the RS232 port through the Tools→Serial Port menu. Then, adjust data rate and line terminator (if any), you can use the serial console as usual.
In this case, you do not need any external Terminal.
If you prefer using an external Terminal, on the PC, open your favorite Terminal application at 38400,n,8,1: HyperTerminal, Teraterm (Windows) or Minicom, GtkTerm (Linux) and CoolTerm (MAC) does the trick.
Note:
“Vintage” serial interfaces are not dead!