Motor and L298N

hello. I have a remote control to which nrf 24 is connected and a receiver with the same module. There is a joystick on the remote and an l298n driver on the receiver. The problem is that the motor does not respond to the joystick. What is the problem? Please help

TX

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#define JOY1 A0
#define JOY2 A1

RF24 radio(9, 10); 


byte address[x][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"}; //возможные номера труб




byte transmit_data[3]; 
byte latest_data[3]; 
boolean flag; 

void setup() {
  Serial.begin(9600); 



  radio.begin(); 
  radio.setAutoAck(1);         
  radio.setRetries(0, 15);    
  radio.enableAckPayload();    
  radio.setPayloadSize(32);     

  radio.openWritingPipe(address[0]);   
  radio.setChannel(0x60);  

  radio.setPALevel (RF24_PA_MAX); 
  radio.setDataRate (RF24_250KBPS); 
  
 

  radio.powerUp(); 
  radio.stopListening(); 
}

void loop() {
  Serial.println(analogRead(JOY2));
  
  transmit_data[0] = map(analogRead(JOY1), 0, 1023, 0, 180); 
  transmit_data[1]=  map(analogRead(JOY2),0,1023,0,255);  
 

  for (int i = 0; i < 3; i++) { 
    if (transmit_data[i] != latest_data[i]) { 
      flag = 1; 
      latest_data[i] = transmit_data[i]; 
    }
  }

  if (flag == 1) {
    radio.powerUp(); 
    radio.write(&transmit_data, sizeof(transmit_data)); 
    flag = 0; 
    radio.powerDown(); 
  }

}


RX


#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <Servo.h>
#define IN1 6
#define IN2 7
#define ENA 8

RF24 radio(9, 10); 
byte recieved_data[3]; 
int pwm;
int motor; 

Servo myservo;

byte address[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"}; 

void setup() {
Serial.begin(9600); 
myservo.attach(2);
motor = recieved_data[1]; 
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
 
  
  radio.begin(); 
  radio.setAutoAck(1);         
  radio.setRetries(0, 15);    
  radio.enableAckPayload();    
  radio.setPayloadSize(32);     

  radio.openReadingPipe(1, address[0]);     
  radio.setChannel(0x60);  

  radio.setPALevel (RF24_PA_MAX); 
  radio.setDataRate (RF24_250KBPS); 
 
 

  radio.powerUp(); 
  radio.startListening(); 
}

void loop() {

Serial.println(recieved_data[1]);   
byte pipeNo;
while ( radio.available(&pipeNo)) {  
    radio.read( &recieved_data, sizeof(recieved_data) );     
    myservo.write(recieved_data[0]);   
    
    
    valX = recieved_data[1]; 
    
    
    
    
    if(valX > 126 && valX < 130){
       digitalWrite(IN1, 0);
       digitalWrite(IN2, 0);
       analogWrite(ENA, 0 );}
    if(valX > 130) {
       valX = map(valX, 130, 255, 0, 255)
       digitalWrite(IN1, 1);
       digitalWrite(IN2, 0);
       analogWrite(ENA, valX );}     
    if(valX < 126) {
       valX = map(valX, 126, 0, 0, 255);
       digitalWrite(IN1, 0);
       digitalWrite(IN2, 1);
       analogWrite(ENA, valX ); }}}

Have you tested the motor and the L298 without the other stuff in play, so that you know at least the motor works at all?

Welcome to the forums. Please take a moment to read the sticky post at the top of the forum about how best to post code (using code tags) and it will help people help you.

You should also request that a moderator move your post from "Installation and Troubleshooting" to a more appropriate topic like "Programming Questions"

In setup(), you declare your enable pin (ENA) as an output, but you never set it to anything. By default, that means the output will be LOW. It usually needs to be HIGH to enable the driver.

yes

Moved :wink:

Hi,
What is the Serial.print sending to the serial monitor on the receiver.
Can you see the NRF receiving any data?

Have you at some stage written code that JUST tests the NRF units and the radio link.

Can you please post a copy of your schematic for both units?
Please show power supplies, all hardware and thier part numbers and pin labels.

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

What kind of power supply are you using? If I have that information I might be able to help you.

powerbank

To power the L298N? How?

5V from arduino

Hi @arduino556665,

what does this line print?

Post a schematic of your receiver.
This will help us to better understand your difficulty.

RV mineirin

Hi,
I understand English is not your native language, you have posted the same question here in the Russian section of the forum.

However we need more information than, yes/no etc.

  1. Can you please post a circuit diagram of your project?
  2. Can you please post a picture of your project?
  3. Can you please post a link to data of your L298N driver, is it just the IC or have you got a shield?
  4. What power supply, Volts, Amps are you using to power the motor?
  5. Can you post a link to data of your motors please?

Have you written some code that JUST USES the NRF modules to establish that your NRF communication is working?

What model Arduino are you using? ( UNO, Nano, Mega ???)

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:
PS. I know it is a lot of information we ask for, but without it we cannot give you accurate answers.

Topic locked due to another post in the russian section.

Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.