I am making a gesture controlled car using mpu6050 and nrf module and l293d ic with motors it is totally not working plz help

the serial monitor is not showing anything and i dont think that the nrf modules are connecting
this is the code
plz help me and if the code is wrong, plz plz plz give me a correct code

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

const int IN1 = 2; 
const int IN2 = 3;   
const int IN3 = 4;  
const int IN4 = 5;   

int data[2];

RF24 radio(9,10);//CE AND CSN

const byte pipe = "00001" ;

void setup(){
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  
  Serial.begin(9600);
  radio.begin(); 
  radio.openReadingPipe(1, pipe);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();             
  }

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

    if(data[0] > 380){
      //forward            
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
    }
    
    if(data[0] < 310){
      //backward              
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
    }
     
    if(data[1] > 180){
      //left
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
    }

    if(data[1] < 110){
      //right
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
    }

    if(data[0] > 330 && data[0] < 360 && data[1] > 130 && data[1] < 160){
      //stop car
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);
    }
  }

this is the transmitter code

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

MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;

int data[2];

RF24 radio(9,10);
                                  
const byte pipe = "00001" ;

void setup(void){
  Serial.begin(9600);
  Wire.begin();
  mpu.initialize();
  radio.begin();   
  radio.openWritingPipe(pipe); 
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop(void){
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  
  data[0] = map(ax, -17000, 17000, 300, 400 ); 
  data[1] = map(ay, -17000, 17000, 100, 200); 
  radio.write(data, sizeof(data));
}```

Where is the transmitter code ?

Why are you reading from the radio object without testing whether any data is actually available ?

Get the radios working by themselves before trying to incorporate them into the overall project. Robin2's simple rf24 tutorial will help with that.

The number one problem that people have with rf24 radios is lack of power. The tutorial discusses that and some remedies.

Reply #30 has a program ( CheckConnection.ino) that can help to verify the wired connection between the processor and its connected rf24.

i have editted the post and added the transmitter code

and i dont know much about nrf module

Are your NRF modules plugged directly into the Arduino or via a carrier board ?

arduino

Then they are probably not working well. Exactly how have you got them connected to the Arduino ?

Daughter boards like this https://www.ebay.com/itm/294227805635?hash=item44815805c3:g:kHQAAOSwAPVZNRBh provide a much more stable electrical environment and take the load off the Arduino board

1 Like

+1 for the rf24 adapter modules. I make my own version and have very little trouble with my rf24 projects.

OP, did you read of the power issues and remedies in robin2's tutorial?

This is very wrong, the pipe address needs to be a 5 byte array.

i actually wanted to buy the adapter but it is not available right now

i will try
i did this by seeing the tutorial by how to mechatronics

i know the power issues and that we have to use an adapter for the nrf
but i will read

Do you have a link?

here is the link

is it reliable

You did not copy it properly, creating your wrong version.

oh thanks

Rewatch around 3:25.

1 Like

The wrong version should also throw warnings, so it seems you have not enabled them.

You should set "Compiler-Warnings" to "All".

ok i will do it

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.