The DigiUSB class helps find, connect to, and talk with Digisparks using the DigiUSB arduino library bundled with the Digispark Arduino software. This class aims to work like an IO object, letting you read and write characters, bytes, and strings as if it were a file, socket, or serial port. To get started, grab a list of Digisparks with the DigiUSB.sparks method. Each spark has an inspect method with a unique identifier including the USB device name (usually DigiUSB), and some numbers representing which ports and hubs each spark connects to. To begin with, DigiUSB.sparks.last works well if you only intend to have one digispark connected to your computer. Eventually the device name (aka “product name”) will hopefully provide a simple way to differentiate different digisparks.

Once you have a reference to a Digispark, you can start using it as if it were an IO object immediately with methods like getc and putc. As soon as you start interacting with the Digispark using these reading and writing methods the Digispark will be claimed to your ruby program and will be unavailable to other programs until you do one of: close the ruby program, or unplug and plug back in the Digispark.

Note also that calling DigiUSB.sparks can sometimes disrupt program uploads, so if you're polling waiting for a digispark to appear you may see some programming errors in the Digispark Arduino software.