nrf24l01 with dc motor control

Hello, i'm making project where i'm supposed to control dc motor and led diode with two nrf24l01 modules.
Idea is that with first push button i control led diode, with second button i control DC motor.

I have made led part, but can't find mistake in motor part. Arduino shows that it understand button, but dc motor still doesn't work.

TX PART

//TX
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define buttonPin1 7
#define buttonPin2 4

int buttonState1 = 0;
int buttonState2 = 0;

RF24 radio(9, 8); // CE, CSN
const byte address[6] = "00002";
void setup() {
  pinMode(buttonPin1, INPUT_PULLUP);
  pinMode(buttonPin2, INPUT_PULLUP);
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);

  LedControl();
  MotorControl();

  radio.write(&buttonState1, sizeof(buttonState1));
  radio.write(&buttonState2, sizeof(buttonState2));

}
void LedControl() {
  if (buttonState1 == 1) {
    buttonState1 = 1;
  }
  else  if (buttonState1 == 0) {
    buttonState1 = 0;
  }
  Serial.print(buttonState1);
  Serial.print("\n");
}
void MotorControl() {
  if (buttonState2 == 1) {
    buttonState2 = 3;
  }
  else  if (buttonState2 == 0) {
    buttonState2 = 2;
  }
  Serial.print(buttonState2);
  Serial.print("\n");
}

RX PART

//RX
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define led1 6
#define mot 5

int buttonState = 0;

int mspeed;


RF24 radio(9, 8); // CE, CSN
const byte address[6] = "00002";

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

  pinMode(led1, OUTPUT);
  digitalWrite(led1, HIGH);

  pinMode(mot, OUTPUT);
  analogWrite(mot, HIGH);

  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
}
void loop() {
  radio.startListening();
  while (!radio.available());
  radio.read(&buttonState, sizeof(buttonState));

  if (buttonState == 1) {
    digitalWrite(led1, LOW);
  }
  else  if (buttonState == 0) {
    digitalWrite(led1, HIGH);
    Serial.print("LED ON");
    Serial.print("\n");
  }
  else if (buttonState == 3) {
    analogWrite(mot, 0);
  }
  else  if (buttonState == 2) {
    analogWrite(mot, HIGH);
    Serial.print("MOTOR ON");
    Serial.print("\n");
  }
}

Well done the way You show code and project.
I wish You would post the wiring diagram also. Else You might be drowning in guesses being wrong, wasting Your and my time.

Railroader:
You might be drowning in guesses being wrong, wasting Your and my time.

i didn't understand this part, i haven't made any guess,yet.

Hi,
Do you have a DMM to measure the voltages around your protoboard?
Please note below.

prototracks.jpg
Can you motor run on that 9V smoke-detector battery?
It will not last long if it can, they are not designed for this sort of application.

Tom... :slight_smile:
PS. As mentioned earlier a circuit diagram will help, (Not a Fritzy picture)

prototracks.jpg

TomGeorge:
Hi,
Do you have a DMM to measure the voltages around your protoboard?
Please note below.

prototracks.jpg
Can you motor run on that 9V smoke-detector battery?
It will not last long if it can, they are not designed for this sort of application.

Tom... :slight_smile:
PS. As mentioned earlier a circuit diagram will help, (Not a Fritzy picture)

Thank you for replay.
Yes dc motor work just fine, din't have any issues with it in previous projects.
I have added shematics in post description

Hi,
I notice you are using the NRF with PA fitted and no aerial, it will work better, and not damage the NRF, if you connect an aerial to each of the units.
The UNO may not be able to provide the surge current needed when the NRF units Tx, you would be advise to place a 10uF capacitor at the NRF power pins.

Please do not go back and add major parts to your posts, this disrupts the flow of the thread and will make it confusing to anyone trying to use this to solve their own problems.

You have a 9V battery in your picture, where is that in your circuit diagram?

Tom... :slight_smile:

Hi,
Do you have a current limit resistor in series with the LED in your Rx?
If not, then please fit a 470R or 1k0 resistor to limit the current drawn from the UNO output.

Tom.. :slight_smile:

TomGeorge:
Hi,
Do you have a current limit resistor in series with the LED in your Rx?
If not, then please fit a 470R or 1k0 resistor to limit the current drawn from the UNO output.

Tom.. :slight_smile:

yes i have, 470R

Hi,
Have you put jumpers across the red and blue breaks on the protoboard, because it looks like the negative of your battery goes nowhere without the jumpers.
Do you have a DMM?

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,
Have you put jumpers across the red and blue breaks on the protoboard, because it looks like the negative of your battery goes nowhere without the jumpers.
Do you have a DMM?

Thanks.. Tom... :slight_smile:

Negativ goes to transitors emitor,
yes i have multimeter

jankeljs:
Negativ goes to transitors emitor,
yes i have multimeter

How does it?
There is a break in the protoboard track between battery negative and the transistor emitter jumper.

prototracksedit.jpg

prototracksedit.jpg

@TomGeorge i have done motor control, but with push buttons, i don’t think that issue would be in shematic

jankeljs:
@TomGeorge i have done motor control, but with push buttons, i don't think that issue would be in shematic

I am not talking about your schematic, I am talking about the protoboard construction.
Do you understand about the links that need to be placed on the board so you will get a circuit from the emitter to the battery negative?
Tom... :slight_smile:
PS. Look at the 9V battery and trace where the negative goes to on the board.

TomGeorge:
How does it?
There is a break in the protoboard track between battery negative and the transistor emitter jumper.

prototracksedit.jpg

nop, these lines are under voltage, checked

Hi,

prototracksedit1.jpg

prototracksedit1.jpg

TomGeorge:
Hi,

prototracksedit1.jpg

at top side 8V and at low side 0v

jankeljs:
at top side 8V and at low side 0v

They should be the same shouldn’t they?
You are assuming that there is continuity down the long red and blue sides of the protoboards, you have just verified that there isn’t.
Tom… :slight_smile:

TomGeorge:
They should be the same shouldn't they?
You are assuming that there is continuity down the long red and blue sides of the protoboards, you have just verified that there isn't.
Tom... :slight_smile:

yeah, previous board was all covered in straight line, would never figure this out.
Thank you TomGeorge for help, and happy holidays :slight_smile:

Hi,
Okay, glad to you have made progress.'
Happy New Year mate.

Tom.... :slight_smile: