This project is a little simple which restricted a lot of options.
I have an Arduino connected to ht12e connected to RF transmitter, and on the other side the receiver is connected to ht12d (decoder) connected to L293D motor driver that controls two motors.
I can send signals and control the motors just fine.
But since I don't have speed control over the motors, because L293D connected to decoder, I ca't seem to think of a way to make the car go left-forward or right-forward and so on.
I included the circuit schematics.
The code of controlling motors is simple and included (note that iam using mpu6050, so ignore it)
void loop(){ //for the mpu6050 library, calling the refresh function is essential to read different values
// we don't need the z value for this project
x = gyro.refresh('A', 'X'); //calling the X-axis from the accelerometer
y = gyro.refresh('A', 'Y'); //calling the Y-axis from the accelerometer
Serial.print("AcX = ");
Serial.print(x); //printing the x-axis angles for the user
Serial.print(" | AcY = ");
Serial.print(y); //printing the y-axis angles for the user
if (x>-50 && x<50 && y>-50 && y<50) { //if the mpu is close to flat position
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW); //turn both motors off
}
else if (x < -50) { //since x-axis is forward and backward, if it is a low negative, turn on motors forward
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,HIGH); }
else if (x > 50) { //if x axis is positive, turn motors in reverse
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,LOW); }
else if (y < -50) { //if y axis angle is below -50 turn the car to right
//doing this is achieved by turning both motors opposite to each other
digitalWrite(8,LOW);
digitalWrite(9,HIGH); //right motor forward
digitalWrite(10,HIGH);
digitalWrite(11,LOW);} //left motor in reverse
else if (y > 50) { //if y axis angle is above 50 turn the car to left
digitalWrite(8,HIGH);
digitalWrite(9,LOW); //right motor in reverse
digitalWrite(10,LOW);
digitalWrite(11,HIGH);} //left motor forward
delay(200);}
