I have an Apple Wireless Keyboard that I love, but it runs on batteries. This little project is how I put a USB wire on it to make it work without batteries. It's still a Bluetooth keyboard, it just runs off of USB power.
To complete this, you'll need:
USB Cable (any kind)
An Apple battery cover (optional)
Soldering iron, wire, hot glue, and miscellaneous tools
I got all of it for about $16 (not including the keyboard).
1. Drill the metal bits
You'll have to drill holes in the battery cover and the "negative" end of one dummy battery. This was by far the trickiest part.
Make the holes just big enough for your USB cable to pass through with the insulation. I was not confident in my ability to nail this on the first try and I didn't want this to be a permanent conversion, so I bought another battery cover. If you're really committed, you could drill the one that came with the keyboard.
2. Run the wires
Here's what I'm calling the wires involved:
New red: A wire you supply that will connect the Vout pin of the AMS1117 to the positive contact inside the dummy battery.
New black: A wire you supply that hooks together the ground of the USB cable, AMS1117, and negative contact inside the dummy battery.
USB red: The red wire that's already inside the USB cable. It will supply +5V to the AMS1117
USB black: The black wire that's already inside the USB cable. It is the ground for all components.
You'll need to drill holes in one end of each battery so a wire can run between them. Run the new red wire all the way through one of the dummy batteries.
Cut the end off of your USB cable and find all of the wires.
Push the USB wire through the drilled battery cover and negative battery terminal. If you buy the same dummy batteries I did, the ends pop out. That's useful for soldering wires to the metal bits without ruining the plastic bits. You have to solder:
The new red wire to:
the positive end of a dummy battery and
pin 2 of the AMS1117
The new black wire to:
the negative end of the other dummy battery and
the usb black and pin 1 of the AMS1117
The usb red to AMS1117 pin 3
Here's the pinout from the chip's data sheet:
When you're finished, it will look kind of like this:
3. Test it
Hook the USB cable up to a power source and make sure you get 3.3V between the positive and negative terminals of your dummy batteries.
4. Glue it
When I was done with soldering, I put a glob of hot glue on the usb wire and pulled it down into the dummy battery so it doesn't move. Then I assembled the batteries and glued the gap between them to keep them stuck together.
The battery cover is not glued to anything. It can spin on the cable. To hook it up, just take the batteries out of your keyboard and put this thing in instead.