This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
digispark:tutorials:digicdc [2015/01/08 00:19] digistump created |
digispark:tutorials:digicdc [2016/06/09 12:03] (current) |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| 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 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. | ||
| + | |||
| + | DigiCDC was based on the V-USB project and avrcdc project - the first version (the hard work) was created by ihsan Kehribar (http://kehribar.me) and then turned into an Arduino library and refined by Erik Kettenburg (Digistump) | ||
| + | |||
| + | === Limitations and Usage === | ||
| 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: | 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: | ||
| - | You must explicitly include the DigiCDC library - by placing the following at the top of your sketch: | + | - You must explicitly include the DigiCDC library - by placing the following at the top of your sketch <code>#include <DigiCDC.h></code> |
| - | <code> | + | - 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 |
| - | #include <DigiCDC.h> | + | - 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. |
| - | </code> | + | - 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() |
| + | - You must install the driver for windows - it is part of the driver package found in the Digispark Arduino release. | ||
| + | - It is slow - it transfers data very slowly (5ms per character) - 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! | ||
| + | - 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. | ||
| + | - 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. | ||
| + | |||
| + | === Examples === | ||
| + | |||
| + | Examples can be found in the Digistump Arduino release (1.5.8C or higher) under File->Examples->DigisparkCDC | ||
| - | 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 | + | === Android Devices === |
| - | 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. | + | DigiCDC can be used to make the Digispark appear as a Serial device to an Android device when attached to an Android device's OTG port. The device must support Serial/CDC devices via OTG |
| - | 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() | + | Android App Examples (using phonegap/cordova and editable with only working knowledge of javascript and HTML): |
| - | You must install the driver for windows - it is part of the driver package found in the Digispark Arduino release. | + | https://github.com/digistump/Digispark_Cordova_CDCLED |
| - | 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! | + | https://github.com/digistump/Digispark_Cordova_CDCEcho |
| - | 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. | + | Phonegap/Cordova Plugin used in the examples above to connect to a DigiCDC device: |
| - | 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. | + | https://github.com/digistump/DigiCDCPhonegap |
| + | (plugin use FTDriver by Keisuke SUZUKI https://github.com/ksksue/FTDriver) | ||