I'm looking for a way to build a USB key. I have a bit of experience with the Arduino, however for this project that seems to be a bit of overkill.

The key should contain a unique serial number (EEPROM?), either to be programmed or factory-set (whatever is easier). Besides the serial number, I need to control 3 LEDs. Each LED has 3 states (on, off & blinking).

I was think to start with a CP2102 based USB TTL UART.

For the EEPROM: AT25010B (SPI) or AT24C01B (I2C) or a dedicated chip

The software (linux) should talk to the RS232 port and be able to retrieve the serial number, and set each LED to the 3 different states.

I read about I2C and SPI. I seems SPI is easier to control, but you need more pins to hook it up.

My questions are:

1) What would be the better protocol I2C or SPI (in terms of 'easy' implementation)?

2) Assuming you can't hookup the LED's and the EEPROM direct to the UART. I need some type PIC to facilitate the communication. What would be a could PIC for this?

Not sure if it matters but: once I have a working prototype, I need to be able to batch produce a few hundreds of these.

  • \$\begingroup\$ If you are familiar with Arduino, why not use a tiny one E.g.1 E.g.2 or make one up using a small Arduino-compatible AVR micro? \$\endgroup\$ May 6 '13 at 10:33
  • \$\begingroup\$ Small microcontroller (ATtiny), hand full discretes and some software: obdev.at/products/vusb/prjdisplay.html USB has room for a serial number by design. \$\endgroup\$
    – jippie
    May 6 '13 at 19:03
  • 1
    \$\begingroup\$ Heck, you could do this with a keyboard IC. Three leds (caps, num, scroll), controllable. \$\endgroup\$
    – Passerby
    May 6 '13 at 20:15
  • \$\begingroup\$ I know, but thought that with a arduino (even the tiny) it feels as overkill. The functional specs are 'super' simple. My lack of knowledge aside, was looking for the simplest (component wise) solution. \$\endgroup\$
    – Roger
    May 6 '13 at 20:34

You don't need an external EEPROM for this. Get a microcontroller with EEPROM instead, that's smaller and easier to use, because you don't need an SPI or I2C module anymore. Also, you can easily program the EEPROM from the computer.

So, basically, you want a PIC or other microcontroller with:

  • (E)U(S)ART connection
  • 3 GPIO pins for the LEDs

Most microcontroller manufacturers have a part selection tool. For microchip, that's MAPS. That's how you can lookup which chip you need.

For these (very minimalistic) requirements, a very small chip enough. Have a look at the PIC12F1822: 8 pins, XLP if you need that, 256 bytes EEPROM, etc. This chip has just enough I/O pins for your three LEDs.

However, from your question it looks like you're a beginner in PIC, and then perhaps a somewhat bigger but easier to interface chip is a better start. Then have a look at the PIC16F88: it has everything you need and more I/O pins, for more LEDs, if needed. The fun of the 16F88 is that it's easier to program it. For the 12F1822, they put everything in a small box and you have to initialize everything (a lot!) correctly, which can be hard, especially for a beginner. The 16F88 is easier to start with.

  • \$\begingroup\$ Super, thanks (absolute beginner!;-). For the moment there are 3 LEDs. I updated the question. I look into those PIC's. \$\endgroup\$
    – Roger
    May 6 '13 at 8:03
  • 1
    \$\begingroup\$ @Rogier you're welcome. I saw your update, the 12F1822 has just enough I/O pins for three LEDs and a serial connection, but I'd strongly recommend you the 16F88! \$\endgroup\$
    – user17592
    May 6 '13 at 8:05

You might be able to get away with just a FTDI USB->serial IC like the FT232R

I have not used one for an application like this but the datasheet says it can have a serial number burned in during manufacture(e.g. for use as a security dongle) and the IO port can be configured to drive LEDs.

The FTDI chip has the advantage that the drivers are common and supported on many platforms.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.