Andrew was kind enough to post additional info on his excellent USB camera project including wiring diagram and source code.
I started this project without really having any idea where it would end up. I started off by deciding it could be interesting to build a device that would sample a 3-axis magnetometer and a 3-axis accelerometer and send that data to my computer via USB. Devices very much like that are often sold as a ’tilt compensated compass’, and go for $250-500. I made mine for about $150.