hi poeple im struggling to find and write some code for the mpu 5060 module, my end goal is to control the direction of some servos (that are hooked up to eyes) in relation to my head movement ie left, right, up and down.
N8-cosplay:
ive read and its still going over my head am im still not on how i use this the control multiple servos ?
Can you read and print the values from the 6050 ?
As you move the 6050 the values will change. Based on the change of values what do you want the servos to do ?
How are the servos and the Arduino going to be powered ? It is not usually a good idea to power servos from the 5V pin of an Arduino as the current available is limited.
hi
the servos have a separate power supply to the uno,(sg90) i currently have three servos set up, one to control up and down movement on the Y axes, one for left movement 90 to 0 and one for right movement 90 to 180 on the X axes.
This is currently set up with a joystick i got with my kit, but im hoping 6050 will allows me to free up my hands and use my head as a on controller ie when i move my head the eyes follow, well that whats im hoping .
can you shed some light on the headache.
thank you
Try the example 6050 programs. Note which values vary when you move it in the required directions. Use the map() function to convert the values to the required range of servo movements and write them to the relevant servo.
Servo servo1;
Servo servo2;
Servo servo3;
int Yaw;
const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
servo1.attach(9);
}
void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); )
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
Run it, hold the 6050 still whilst it is calibrated then move it an observe the readings changing. Once you know which angle you want to associate with the servo you can take the angle and convert it into servo movement.
This forum is not a free code writing service. It’s for getting help with the code you’ve written. If you want help, you must post your best attempt and ask specific questions. So far, you’ve shown no attempt to do this.
hi
sorry just struggling but after reading though everything again and again and having a break and looking at everything with fresh eyes and just having you guys to bounce off and thank you for that, ive got something that has clicked and ive got a little way to go to get all that i what to happen working and i will share when im done as a thank you