User Tools

Site Tools


digispark:tutorials:digicdc

This is an old revision of the document!


DigiCDC - Digispark USB CDC Serial Library

The DigiCDC library allows the Digispark or Digispark Pro to appear to a computer as a Virtual Serial Port when connected by USB. This makes it appear just like a standard Arduino and allows the use of the Serial Monitor built into the Arduino IDE.

The DigiCDC library is based on V-USB - because the Digispark does not have hardware USB support. This presents some unique limitations in how it works - outlined below:

  1. You must explicitly include the DigiCDC library - by placing the following at the top of your sketch
    #include <DigiCDC.h>
  2. It uses a lot of RAM - half of the Digispark's RAM - so only include it when needed and watch your RAM usage. You can wrap strings in F() (ie. SerialUSB.print(F(“test”)) ) to put the string in flash memory instead of RAM
  3. You use it the same as Serial on an Arduino but with SerialUSB instead (ie. SerialUSB.read() instead of Serial.read() ) - The Pro also has Serial defined - but that refers to the hardware Serial port on Pins 6 and 7.
  4. The begin statement does not need a baudrate - it is a CDC device so it does not have a set baud rate - just use SerialUSB.begin()
  5. You must install the driver for windows - it is part of the driver package found in the Digispark Arduino release.
  6. It is slow - it transfers data very slowly - because it is a low speed USB device doing the job of a Standard speed device - and doing it all virtually without actual hardware support!
  7. Like all of our V-USB libraries you must use its delay function instead of delay() - so use SerialUSB.delay() when you need a delay in your code.
  8. SerialUSB.delay() or SerialUSB.refresh() must be called every 10ms or less in your code if no other SerialUSB call is made in that code.
digispark/tutorials/digicdc.1420706446.txt.gz · Last modified: 2015/01/08 00:40 by digistump