# I'd like to learn how to make my own USB gadgets

I've been writing Linux character device drivers for other people's stuff for some time. I'd like to find a new hobby and the thought of making my own USB gizmos seems really neat.

I would be thrilled to be able to control some LEDs, servos, and step motors. I really enjoy learning new things on my own and the excitement when something finally works. I've not done any serious MC programming, but do know my way around.

Can anyone recommend some kits that would be helpful to a complete noob? Ideally, they are:

• Linux Friendly
• Able to ship internationally (I'm currently living in Asia)

If you have the time and inclination, links to projects on other people's sites that include schematics and parts lists would be greatly appreciated. I want to study from examples, but good examples, which is why I'm asking here.

My eventual goal is to make my own data collectors - everything from rainfall to average decibels to light levels. Sorry if this has been asked before, I did search (and searched tags).

The Arduino is really popular, and it is open-source hardware, so there are variations, including the third-party Freeduinos called Bare Bones Board, the Really Bare Bones Board, and the Boarduino, which are very nice for using with breadboards. The standard Arduino is adapted using things called Shields. You can make your own breadboard shield or buy something like this ProtoShield Kit.

The Arduino uses an FTDI USB-RS232 chip or cable. [The standard Arduino has it build in, while the most of the bread board ones use a special cable that has the chip inside, and saves you some money.] There is a built-in driver for Linux, and Mac OS X and Windows users can download a driver. Effectively, this means that the Arduino acts as a device communicating on a serial port, and so it is very easy to communicate with.

To use it, you also download software. It comes with an IDE, an AVR-GCC toolchain, a really nice library, and software to upload your program on to the chip. It hides most of the details from you, and has a great community. It is programmed in a language called "Wiring", but it is really C++.

Lastly, being open-source hardware, there are schematics out there. Indeed, I seem to recall reading that it was fairly easy to build an earlier model. Searching for "Arduino schematics" in your favourite search engine will give you good results.

As for kits, the Maker Shed offers a lot of Arduino-related items in stock. They appear to ship around the world. Some ones of interest include:

The Shoppe at Wulfden (USA) has a nice experimenters kits, and appears to ship internationally.

Solarbotics (Canada) has a ARDX Arduino Experimenter's Kit, a Freeduino Starter Bundle - Ultimate and an Arduino Starter Bundle - Basic (and Ultimate), and appears to ship internationally.

The main Arduino's "buy" page lists Arduino vendors in all areas of the globe.

Other places I would check include Adafruit Industries and Sparkfun Electronics (both in the US).

• Wow. Thank you for the time that you put into such an informative answer! – Tim Post Nov 8 '09 at 4:48
• I'm glad to hear it. After I wrote the answer, I thought to myself, "I can't believe I just spent forty minutes answering a question on the internet!" – Clinton Blackmore Nov 9 '09 at 17:26
• Great post, but it should be noted that not all Arduinos use the FTDI chip. For example, I use my Arduino Uno R3 under OS X with no driver installed. (That one uses an Atmega 16U2 for USB communication.) – exscape Mar 7 '12 at 18:53

The Arduino is a great tool to start with when you want to build electronic gadgets and it might lead you to your eventual goal of building a datalogger. However, it is not suitable for real USB development as it emulates an old fashioned serial port. It won't let you make it into anything else (like a Human Interface Device (mouse/keyboard) or a Mass Storage Device (cardreader/removable drive)).

If you want to make "real" USB gadgets check out the site of Jan Axelson. He writes "beginners" books about USB. Developing gadgets that use USB on this level might not be suitable for beginners though so Arduino experience will definitely get you on your way.

• Thank you for the link. I will surely check it out once the 'training wheels' come off :) – Tim Post Nov 8 '09 at 5:08
• That's not quite true... Arduino Leonardo and all Atmega32u4 based boards can let you make HID and any other custom devices – Dmitry Gusarov Apr 1 '18 at 15:28

I highly recommend the Tuxgraphics AVR USB slideshow presenter tutorial. It uses an Atmel AVR microcontroller, which has a large hobbyist community (avrfreaks etc), and an open-source software-only usb1.1 stack from obdev.org. It can't scale up very high (mass storage, for example), but the final product is a little USB HID keyboard with two assignable pushbuttons. It would be trivial use it as a datalogger, and a few of the examples at obdev.org are just that ( www.obdev.at/products/vusb/projects.html ). It's written in clean c, and the parts list is a few dollars at most.

At the same time, I recommend building or buying the tuxgraphics avrusb500 programmer. It's a joy to use, and one of the most reliable pieces of equipment I own. (I'm not affiliated -- just a very satisfied customer!)

Another device I've wanted to look into is the AT90USBKey. It has been a while since I've looked into it, and I'm not certain if you can program for it without Windows, but it will act as a USB device (like a keyboard or mass storage device) or as a USB host that you plug other devices into. There are sample programs available, and it looks reasonably easy to work with, provided you know a little bit about electronics and can code in C.

A google search for AT90USBKey and Linux yileds promising results.

I know you can get it from DigiKey.ca. I looked up a digikey equivalent for Asia; you can get the part from Farnell.

• According to the linked site, it looks like the board can be programmed via Jtag. – SingleNegationElimination Sep 15 '10 at 4:43

You might also want to check Teensy.

If you end up using the Arduino I have ported the V-USB (formerly AVR-USB) library to run on it. It is also wrapped with a class to make interaction easier.

You can create USB HID devices with it, e.g. keyboard, mouse, or joystick. You can also create a generic device that uses libusb on the host to control it--from Python, C, Processing etc.

My site has a PCB shield you can make that uses a USB socket and a few resistors etc:

http://code.rancidbacon.com/ProjectLogArduinoUSB

You can write Arduino code to send keystrokes as easily as:

UsbKeyboard.sendKeyStroke(KEY_ENTER);


or with a libusb "driver" you can send data like:

UsbStream.write(0xff)


UsbStream.read()


--Philip;

There are a number of AVR-USB based developer boards now.

I've personally used the before-mentioned Teensy and Bumble-B and think they're both great.

Teensy is nice, because it integrates really well with the Arduino environment. This means you can do things like "Mouse.init; Mouse.move(x,y)" instead of dealing with the low-level USB code yourself. Both will run LUFA if you want it, though.

Here's a simple PIC USB project of mine:

http://www.leonheller.com/usb

PCBs are available.

Object Development has made a library for AVR microcontrollers that enables you to make very cheap USB devices on your own (starting at just 2-3\$). GCC for AVR is linux friendly. There are hudreds of devices already made. Take a look here: http://www.obdev.at/products/vusb/projects.html

It depends on what kind of usb gadgets you want to make, and on how advanced level. You mention blinking leds. That kind of control can be easily archieved with any kind microcontroller with uart and a ftdi chip (arduino is pretty popular, and easy to begin one). The ftdi chip connects to the uC serially, and acts like a serial <-> USB converter. It also shows up as a virtual COM-port on your computer.

If you want to make use of more advanced usb protocols, drivers and features, you could get a uC with native usb capability. Microchip has many pics (their microcontrollers) that can do this, for example. Microchip also has many development boards dedicated to learning to use the usb. Atleast Microchips 32-bit uC support also host, and otg -modes, so you could build a datalogger that saves the data to a common usb memory stick, which you could plug to your computer to read the data. (I am sure many other manufacturers also have similar ICs and dev-kits, but Microchip is the only one I have used)

Microchip's homepage/USB

Note that you don't have to start at such a low electronic level and spare more development time for the "gizmo" itself. Many companies sell USB devices for the DIY market, for instance:

http://www.yoctopuce.com

http://www.phidgets.com