Step 41: Code for use with new 6dof DIGITAL IMU from Sparkfun

There is a problem as most of the analog output IMU's are vanishing from stores and being replaced with digital ones.
I have looked at the Sparkfun 6dof Digital IMU and tried to incorporate code to read the digital output from this into my existing self balance code. Did not want to do it, but this is coming so someone has to have to have a go else nobody will build any more hobby self-balancing machines.

I have used code from the web, full wiring instructions and orientation instructions are given in the attached arduino sketch.

Code to read the IMU came from here:

I have built it into my existing code for a self balancing 2 wheeler that uses rocker switches or buttons for steering and adjustment of balance point.

It is set up at present so you can test it with the IMU attached to an Arduino watching the outputs on an attached computer.

If you want to run it in a real machine then there is a section of code to comment out which then enables all the buttons including the deadman switch.
At present I am using pulldown resistors to GND on the button input pins as in my original instructable here.

NOTE: Unfinished. Not sure if even works but is here as a start for others to work with.

Remove these adsRemove these ads by Signing Up
pbecker831 year ago
Has anyone written any complete code for the more common digital IMU's? I am getting to the electronics part of my build but my 5DOF's got held up in customs and I have no idea when or if Ill get them now. Wouldn't mind ordering a digital one if I can find some instructions/code that tried and true. Thanks!
him2anshu2 years ago
Can you please add the 6DOF digital code again please, its been removed again, or mail me at
davidwjib2 years ago
Could you re-post your code that works with the digital 6DOF IMU please?
Delpap3 years ago
Could you send the code please, my email address is:
ld'sa3 years ago
Hi Xenon,

i am working on a self balancing bot
even i checked out this website

but i need help with the variables to take in order for my code to perform calculations
because it is a digital IMU (6dof) i am facing a lot of problems as i am a beginner. If you could help me out i am will to share my details with you so other guys can also use it for their projects