Hello, all. We are trying to get a self-balancing robot working using an Arduino Uno, MPU 6050, and the PololuQik 2s9v1.
Arduino Motor Controller MPU
Gnd Gnd Gnd
The MPU interrupt “wants” to be on pin 2, which is taken by Tx on the motor controller.
We are able to run the Pololu Demo, and if we switch the MPU Int to 2, we can get data from that.
We tried to use attachInterrupt to use pin 5 for the MPU interrupt, but that doesn’t work.
Do I need to use some other method?
Code is attached, borrowed heavily from Arkadi Rafalovich’s code from this forum. I don’t have the link, but I will add it later…
Any help is appreciated…
Mini_Self_Balancing_Modes_pololu.ino (16.5 KB)
I don't use the interrupt pin on the 6050, just set up a basic time check so you don't read it to often. You can pull the data from it any time you want.
Why not use the MOSI, MISO, or SCK pins, they should be interrupt pins.
As difficult as it might sound, when your trying to change how a library works, you might as well just go into the library and tear the code right out of it and put it directly into your sketch. Then you can make it do whatever you want.
In a lot of cases the code really isn't that long or complicated, but is surrounded by a lot of supporting code so they can use keywords, which you just don't need.
I was using the Interrupt method only because I am very new, and wanted to adapt from: http://forum.arduino.cc/index.php?topic=143261.0
I’m not sure where to start with using the fixed time approach, but I’ll certainly research that method.
From: Arduino - SPI I gather that MISO is pin 12, so if I attachInterrupt(12,dmpDataReady, RISING);
this might work? Or do I need to point the code to ISCP-1 somehow?
I am certainly learning more about how to hack on libraries, so that’s good.
Thanks for the feedback, I’ll check out the other approach as well…