Servo motor and gyroscope

Is there a way to get one servo to rotate counterclockwise. And the other to rotate clockwise while still using the same axis of the gyroscope. I am operating 2 servos with a mpu6050.

jbraightmeyer:
Is there a way to get one servo to rotate counterclockwise. And the other to rotate clockwise

Yes. Write a value to one servo that turns it CCW. Write a different value to the other servo that turns it CW.

while still using the same axis of the gyroscope.

I am guessing that you are using the output of one axis of a gyro to control the servo behavior. You will probably have to do a bit more describing of how the gyro values control the servos.

I am very new to programming so I can’t really explain the values. I will try to upload my code so you can understand what i am trying to do.

Good idea.
And since you are new, go read through the How to use this forum - please read sticky post that has much great info for new members.

So I ended up using this guys code and editing it to work 4 servos. https://maker.pro/education/diy-constant-current-source-power-supply-circuit

For some reason it isnt letting me attach a picture of my code

jbraightmeyer:
For some reason it isnt letting me attach a picture of my code

Don't attach a picture of code. Post the code using code tags, as is fully documented in the sticky post I linked to in reply #3 above.

Here is the code ive been using

#include <Wire.h>

#include <MPU6050.h>

#include <Servo.h>   

Servo sg90;  
Servo sg91;
Servo sg92;
Servo sg93;        

int servo_pin0 = 8;
int servo_pin1 = 9;
int servo_pin2 = 10;
int servo_pin3 = 11;

MPU6050 sensor ;

int16_t ax, ay, az ;

int16_t gx, gy, gz ;

void setup ( )

{ 

sg90.attach ( servo_pin0 );
sg91.attach ( servo_pin1 );
sg92.attach ( servo_pin2 );
sg93.attach ( servo_pin3 );

Wire.begin ( );

Serial.begin  (9600); 

Serial.println  ( "Initializing the sensor" ); 

sensor.initialize ( ); 

Serial.println (sensor.testConnection ( ) ? "Successfully Connected" : "Connection failed"); 

delay (1000); 

Serial.println ( "Taking Values from the sensor" );

delay (1000);

}




void loop ( ) 

{ 

sensor.getMotion6 (&ax, &ay, &az, &gx, &gy, &gz);

ax = map (ax, -17000, 17000, 0, 180) ;
ay = map (ay, -17000, 17000, 0, 180) ;


Serial.println (ax);
Serial.println (ay);

void reverse() {
sg90.write (ax); 
}

sg91.write (ax); 

sg92.write (ay); 

sg93.write (ay); 

delay (000);

}

Thank you for all the help