When I looked for usb connectors to buy, I found that there are 4 pins and 5 pins options. Which one should I buy? Which is the more popular one? Are there simple ways to handle both?
Depends on what you are trying to do but if you are trying to build some type of USB peripheral for a PC I find these the easiest to use by far:
The spacing on the 4 pins work well with .1" spaced protoboards and the tabs can be put through the board too and soldered down on the other side with a little bit of widening from a drill. With those 6 points soldered, it’s pretty solid even on a protoboard. The plus for this connector is this is the connector that is used for almost every desktop USB device so if you own a printer, a scanner, or almost anything, you probably already own this cable. In fact, you probably already own ten of them.
5 pin connectors contain an ID pin which is not really needed but it can be used to distinguish host (connected to GND) from slave (floating). If you want to make something miniature, use the 5 pin micro connector, but be prepared for surface mount soldering or buy a breakout like this:
A project I recently started that has a working USB port. This is based on the Happy Gecko M0.