Help for arduino hand controlled car

Hello everyone.
I want to make the most controlled car with Arduino.
I used 1 arduino nano, 1 MPU6050 6 Axis Acceleration and Gyro Sensor, 1 nRF24L01 2.4GHz Wireless Module for hand control. The necessary connections were made. Gyro sensor is working.
The code used for the transmitter:

#include <SPI.h>
#include <RF24.h>
#include <Wire.h>
#include <MPU6050.h> //Mpu6050 library 

MPU6050 acceleration_sensor; 
int x, y, z; //defining acceleration

RF24 radio(7, 8); // CE, CSN
int data[2]; // Defining array for X and Y plane

void setup() 
{
Wire.begin();
ivme_sensor.initialize();

radio.begin();
radio.openWritingPipe(1234);

}

void loop() 
{

acceleration_sensor.getAcceleration(&x, &y, &z); // read acceleration and gyro values
    
data[0] = map(x, -17000, 17000, -255, 255 ); //X plane data (forward-backward)
data[1] = map(y, -17000, 17000, -255, 255); //Y plane data (right-left)
radio.write(data, sizeof(data));
}

I used arduino toolkit for the receiver. I used L298N motor driver, arduino uno, the sensor used for the transmitter. I connected a 9v battery to both arduino uno and l298n motor driver differently to power it.

The code used for this:

#include <SPI.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN

int data[2];// X ve Y düzlemi için dizi tanımlama

int in1 = 5;
int in2 = 6;
int in3 = 9;
int in4 = 10;

void setup() {
radio.begin();
radio.openReadingPipe(1,1234);
radio.startListening();
}

void loop() {
  if (radio.available()) {
    
radio.read(data, sizeof(data));

    if(data[0] > 50)//ileri
    {
      analogWrite(in1,data[0]);
      analogWrite(in2,0);
      analogWrite(in3,data[0]);
      analogWrite(in4,0);
    }
    if(data[0] < -50)//geri
    {
      analogWrite(in1,0);
      analogWrite(in2,-data[0]);
      analogWrite(in3,0);
      analogWrite(in4,-data[0]);
    }
  
      if(data[1] > 50)//sol
    {
      analogWrite(in1,0);
      analogWrite(in2,data[1]);
      analogWrite(in3,data[1]);
      analogWrite(in4,0);
    }
      if(data[1] < -50)//sag
    {
      analogWrite(in1,-data[1]);
      analogWrite(in2,0);
      analogWrite(in3,0);
      analogWrite(in4,-data[1]);
    }
    if(data[0] > -50 && data[0] < 50 && data[1] > -50 && data[1] < 50)//dur
    {
      analogWrite(in1,0);
      analogWrite(in2,0);
      analogWrite(in3,0);
      analogWrite(in4,0);
    }
    
  }
}

These are the codes. But I think that the data from the transmitter is not going to the receiver because the vehicle is not moving. What should I do about this. I am waiting for your help.

Hi, @moonbanana

If the 9V battery is one of these;

Then it will not have the capacity to power much, especially a controller and motors.

Can you post some images of your project?
So we can see your component layout.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Did you write your code in stages and get each stage working?
For example use the example code for the RF24 library to first establish comms between your remote control and the car?

Tom.... :smiley: :+1: :coffee: :australia:

sounds like you put everything together without indiidually testing the components

write some test code that

  • verifies the operation of the motor
  • verifies the operation of the radio