Gesture controlled car

Hello,
So I'm a beginner and I am making a gesture controlled car, the main thing here is that my adxl335 got corrupted and so I'm planning on using another mpu6050 instead, but I am a little scared that would it go well with the code or will I need to make some changes.
Here's the code :arrow_down:

int xPin=A0;
int yPin=A1;

int out1=8; //output1 for HT12E IC
int out2=9; //output1 for HT12E IC
int out3=10; //output1 for HT12E IC
int out4=11; //output1 for HT12E IC

void setup(){
pinMode(xPin,INPUT);
pinMode(yPin,INPUT);

pinMode(out1,OUTPUT);
pinMode(out2,OUTPUT);
pinMode(out3,OUTPUT);
pinMode(out4,OUTPUT);
}

void loop()
{
int xval=analogRead(xPin);
int yval=analogRead(yPin);

if ((xval>294 && xval<340) && (yval>294 && yval<340)) //stop
{
digitalWrite(out1,LOW);
digitalWrite(out2,LOW);
digitalWrite(out3,LOW);
digitalWrite(out4,LOW);
}

else
{
if ((xval>340 && xval<380) && (yval>294 && yval<340)) //forward
{
digitalWrite(out1,HIGH);
digitalWrite(out2,LOW);
digitalWrite(out3,HIGH);
digitalWrite(out4,LOW);

}
if ((xval>345 && xval<294) && (yval>294 && yval<340)) //backward
{
digitalWrite(out1,LOW);
digitalWrite(out2,HIGH);
digitalWrite(out3,LOW);
digitalWrite(out4,HIGH);

}

if ((xval>294 && xval<340) && (yval>340 && yval<380)) //left
{
digitalWrite(out1,HIGH);
digitalWrite(out2,LOW);
digitalWrite(out3,LOW);
digitalWrite(out4,LOW);
}

if ((xval>294 && xval<340) && (yval>340 && yval<294))//right
{
digitalWrite(out1,LOW);
digitalWrite(out2,LOW);
digitalWrite(out3,HIGH);
digitalWrite(out4,LOW);

}
}
}

Please help if u know the way, I'd love to learn.
Thank u and have a nice day ahead!
P.S. - Here's a link from where I found the project

What is your question?

The MPU6050 is considerably more versatile than the ADXL335 but that makes it more complicated to use. Your code will need quite some changes. For one thing the MPU6050 is an I2C device, so you can't use analogRead() to get data from it.

There are several MPU6050 libraries and projects with example code available so it shouldn't be impossible.

Steve

Thank u soo much!!