Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and NRF24L01 Controlled Motor System with Pushbutton and BTS7960 Driver

View and Edit Project In Cirkit DesignerImage of Arduino UNO and NRF24L01 Controlled Motor System with Pushbutton and BTS7960 Driver

Circuit Documentation

Summary

This circuit is designed to control a 250W 12V DC motor using an Arduino UNO, a BTS7960 motor driver, and an NRF24L01 wireless module. The motor's speed and direction are controlled based on signals received from another NRF24L01 module. A pushbutton is used as an ON/OFF switch for the Arduino.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. BTS7960 Motor Driver

    • Description: A high-power motor driver module.
    • Pins: Pin 1, Pin 2, Pin 3, Pin 4, Pin 5, Pin 6, Pin 7, Pin 8, Pin 9, Pin 10, Pin 11, Pin 12
  3. 250W 12V ELECTRIC MOTOR BRUSH MOTOR DC

    • Description: A 250W 12V DC motor.
    • Pins: POSITIF, NEGATIF
  4. Battery 12V

    • Description: A 12V battery for powering the motor.
    • Pins: -, +
  5. NRF24L01

    • Description: A wireless transceiver module.
    • Pins: IRQ (not used), MOSI, CSN, VCC (3V), GND, CE, SCK, MISO
  6. Pushbutton

    • Description: A simple pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  7. 3.7V Battery

    • Description: A 3.7V battery for powering the Arduino and NRF24L01.
    • Pins: +, -

Wiring Details

Arduino UNO

BTS7960 Motor Driver

250W 12V ELECTRIC MOTOR BRUSH MOTOR DC

Battery 12V

NRF24L01

Pushbutton

3.7V Battery

Code Documentation

/*
 * This Arduino sketch receives signals from another nRF24L01 module and uses
 * those signals to control a motor via the BTS7960 motor driver. A pushbutton
 * is used as an ON/OFF switch for the Arduino.
 */

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

// Pin definitions
#define CE_PIN 7
#define CSN_PIN 8
#define MOTOR_EN_PIN 5
#define MOTOR_PWM_PIN 6
#define MOTOR_DIR_PIN 4
#define MOTOR_BRAKE_PIN 3
#define BUTTON_PIN 2

// Create an RF24 object
RF24 radio(CE_PIN, CSN_PIN);

// Address for the nRF24L01 communication
const byte address[6] = "00001";

// Variable to store received data
int motorSpeed = 0;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize the nRF24L01 module
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();

  // Initialize motor control pins
  pinMode(MOTOR_EN_PIN, OUTPUT);
  pinMode(MOTOR_PWM_PIN, OUTPUT);
  pinMode(MOTOR_DIR_PIN, OUTPUT);
  pinMode(MOTOR_BRAKE_PIN, OUTPUT);

  // Initialize button pin
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  // Set initial motor state
  digitalWrite(MOTOR_EN_PIN, LOW);
  digitalWrite(MOTOR_BRAKE_PIN, HIGH);
}

void loop() {
  // Check if the button is pressed
  if (digitalRead(BUTTON_PIN) == LOW) {
    // If button is pressed, enable the motor
    digitalWrite(MOTOR_EN_PIN, HIGH);
    digitalWrite(MOTOR_BRAKE_PIN, LOW);
  } else {
    // If button is not pressed, disable the motor
    digitalWrite(MOTOR_EN_PIN, LOW);
    digitalWrite(MOTOR_BRAKE_PIN, HIGH);
  }

  // Check if data is available to read
  if (radio.available()) {
    // Read the data
    radio.read(&motorSpeed, sizeof(motorSpeed));

    // Set motor speed and direction
    if (motorSpeed >= 0) {
      digitalWrite(MOTOR_DIR_PIN, HIGH);
      analogWrite(MOTOR_PWM_PIN, motorSpeed);
    } else {
      digitalWrite(MOTOR_DIR_PIN, LOW);
      analogWrite(MOTOR_PWM_PIN, -motorSpeed);
    }
  }
}

This code initializes the NRF24L01 module for wireless communication, sets up the motor control pins, and reads the state of the pushbutton to control the motor. The motor speed and direction are adjusted based on the received signals from another NRF24L01 module.