I am a little bit confused. I know, there is at least hundreds of examples over the Internet, but I still can not figure it out. The thing is I don't want to copy something and thats it, I want to do it by myself, learn and understand what I did.
I am using Arduino Mega plus MPU6050, the MPU is working perfectly fine, and I can see the yaw pitch an roll values with the DPM example made by jrowberg, my problem is, how can I work with that values and then put them through my pwm ports to control both motors?
I even tried with 2 leds, but still I can not make it work.
Tell us about the rest of the robot and its wiring. What motors, motor drivers, batteries, etc. are you using?
Post the code that you have, using code tags ("</>" button).
I must say you are a really good maker who are fond of creating. You want to do it by yourself, learn and understand what you did. That's cool!
But sometimes, you can find some reference and have a look at others' projects for reference, that can be of great help for your project and make your making easier maybe. As for the self balancing robot, you can also have a look at how other people do and then make your own robot. For example, you can see the project in http://www.elecrow.com/freescale-mc9s12xs128mal-2wheel-selfbalancing-robot-p-878.html, it is a successful project and maybe it can help.
Ok, so as requested I attached the code and my schematic.
I know that the schematics are wrong on the Motor Controller Side, It does not matter now because I want to control just 4 LEDS with PWM.
1 LED - FORWARD
1 LED - BACKWARD
1 LED - LEFT
1 LED - RIGHT
After I manage to put this to work I can easily do the circuit with the motor with some L292 or L293D depend on the motors.
So again my question is, how can I work with the DMP values and then put them through my pwm ports to control the LEDs?
Thanks in advance for your time.
Best regards
NesquickPT
Only one number output by the sensor is of interest, and that is the tilt away from vertical. Since you apparently don't have a robot with the sensor mounted, it is impossible to determine which that might be.
The way it should work: if the robot tilt is increasing away from the vertical, you activate a motor in the correct direction to correct that trend.