Hello, i need a program that can controll 3 servoes using mpu6050. I need that the 3 gyroscope axis equal to the angle of the servoes. I have tried to do this but after a while the servoes stop and don't move anymore.
#include <MPU6050_light.h>
#include"Wire.h"
#include <Servo.h>
Servo servo1;
Servo servo2;
MPU6050 mpu(Wire);
unsigned long timer = 0;
int x, y, z;
void setup() {
Serial.begin(9600);
Wire.begin();
byte status = mpu.begin();
mpu.calcOffsets();
servo1.attach(5);
servo2.attach(6);
}
void loop() {
mpu.update();
x = mpu.getAngleX();
y = mpu.getAngleY();
z = mpu.getAngleZ();
timer = millis();
servo1.write(x);
servo2.write(z);
}
Like 4 x AA NiMH rechargeable batteries (e.g. Eneloops). And connect them direct to the servos. It's never a good idea to power servos from the Arduino 5V pin.
Why not put some Serial prints in so you can see what you're actually writing to the servos?
ok so i will try to use 4 AAA batteries for power the servoes and i will also try to get the data from the serial monitor to see what is going to be written on the servo