Maker 101
Published © GPL3+

Wireless Arduino Motor Driver and Joystick Controller

Arduino based wireless dual-motor driver board, it has an nRF24L01 transceiver module, dual L293D motor driver and an Arduino Nano V3

IntermediateFull instructions provided4 hours5,835
Wireless Arduino Motor Driver and Joystick Controller

Things used in this project

Hardware components

Arduino Nano V3
×2
L293D IC
×2
nRF24L01 Transceiver
×2
10uF Capacitor
×2
Joystick Module
×1
Male Female Header
×1
Breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematic for Motor Driver

Code

Remote_Control_transmitter.ino

Arduino
#include <SPI.h>  //the communication interface with the modem
#include "RF24.h" //the library which helps us to control the radio modem

//define the data pins
int joyX = A1;
int joyY = A2;

//define variable values
int dataX;
int dataY;

int data[2];

RF24 radio(10,9); //10 and 9 are a digital pin numbers to which signals CE and CSN are connected
                                      
const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem, that will receive data from Arduino


void setup(void){
  Serial.begin(9600);
  radio.begin();                      //it activates the modem
  radio.openWritingPipe(pipe);        //sets the address of the receiver to which the program will send data
}

void loop(){
  //Send signal data
  dataX = analogRead(joyX);
  dataY = analogRead(joyY);
  
  data[0] = dataX;
  data[1] = dataY;

  Serial.print("Data X:"); Serial.println(dataX);
  Serial.print("Data Y:"); Serial.println(dataY);
  radio.write(data, sizeof(data));
  
}

Remote_Control_receiver.ino

Arduino
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem (nRF24L)

//Motor A
const int RightMotorForward = 2;    // IN1
const int RightMotorBackward = 4;   // IN2

//Motor B
const int LeftMotorForward = 7;     // IN3
const int LeftMotorBackward = 8;    // IN4


int data[2];

RF24 radio(10, 9); //10 and 9 are a digital pin numbers to which signals CE and CSN are connected

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino


void setup() {
  Serial.begin(9600);
  pinMode(RightMotorForward, OUTPUT);
  pinMode(LeftMotorForward, OUTPUT);
  pinMode(RightMotorBackward, OUTPUT);
  pinMode(LeftMotorBackward, OUTPUT);

  radio.begin();                    //it activates the modem
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data
  radio.startListening();           //enable receiving data via modem
}

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

    //data X
    if (data[0] > 550) {
      digitalWrite(RightMotorForward, HIGH);
      digitalWrite(RightMotorBackward, LOW);
      digitalWrite(LeftMotorForward, HIGH);
      digitalWrite(LeftMotorBackward, LOW);
      Serial.println("FORWARD");
    }

    //data X
    if (data[0] < 400) {
      digitalWrite(RightMotorForward, LOW);
      digitalWrite(RightMotorBackward, HIGH);
      digitalWrite(LeftMotorForward, LOW);
      digitalWrite(LeftMotorBackward, HIGH);
      Serial.println("BACKWARD");
    }

    //data Y
    if (data[1] > 550 ) {
      digitalWrite(RightMotorForward, LOW);
      digitalWrite(RightMotorBackward, HIGH);
      digitalWrite(LeftMotorForward, HIGH);
      digitalWrite(LeftMotorBackward, LOW);
      Serial.println("TURN RIGHT");
    }

    //data Y
    if (data[1] < 400 ) {
      digitalWrite(RightMotorForward, HIGH);
      digitalWrite(RightMotorBackward, LOW);
      digitalWrite(LeftMotorForward, LOW);
      digitalWrite(LeftMotorBackward, HIGH);
      Serial.println("TURN LEFT");
    }

    if (data[0] < 550 && data[0] > 400 && data[1] < 550 && data[1] > 400) {
      digitalWrite(RightMotorForward, LOW);
      digitalWrite(RightMotorBackward, LOW);
      digitalWrite(LeftMotorForward, LOW);
      digitalWrite(LeftMotorBackward, LOW);
      Serial.println("STOP");
    }

  }
}

Credits

Maker 101

Maker 101

42 projects • 172 followers
Maker 101; Beginner and intermediate level Maker projects!

Comments