Introduction: Radio Frequency - Joystick Control Bot
In this instructable I will be showing you how to build a radio frequency - joystick control robot. This bot movements are controlled with the help of a joystick and it is completely wireless as in this I have used a RF 433 MHz transmitter reciever module. What surprises me is that it really does not mess up.
This was just a short introduction, everything else from theory, building, and programming will be explained in later steps.
Parts List:-
- Arduino Nano - 2
- RF 433 Mhz Transmitter-reciever module - 1
- L293D - 1
- Joystick - 1
- Breadboard -1
- Cardboard - As per required
- Caster wheel - 1
- BO motors - 2
- BO motor wheels - 2
- LiPo Battery - 1
- Jumper Wires - As per required
Step 1: Module Specification
We have used RF transmitter-reciever module(As shown in above figures) to transmitt data from our joystick to the robot.
This module has a specification for:-
Transmitter :
Working voltage: 3V - 12V fo max. power use 12V
Working current: max Less than 40mA max , and min 9mA
Resonance mode: (SAW)
Modulation mode: ASK
Working frequency: Eve 315MHz Or 433MHz
Transmission power: 25mW (315MHz at 12V)
Frequency error: +150kHz (max)
Velocity : less than 10Kbps
So this module will transmit up to 90m in open area .
Receiver :
Working voltage: 5.0VDC +0.5V
Working current:≤5.5mA max
Working method: OOK/ASK
Working frequency: 315MHz-433.92MHz
Bandwidth: 2MHz
Sensitivity: excel –100dBm (50Ω)
Transmitting velocity: <9.6Kbps (at 315MHz and -95dBm)
NOTE:- the use of an optional antenna will increase the effectiveness of your wireless communication. A simple wire will do the trick.
Joystick -
Analog joysticks are a great way to add some control in your projects.
We need 5 connections to the joystick.
The connection are : Key, Y, X, Voltage and Ground. "Y and X" are Analog and "Key" is Digital.
If you don't need the switch then you can use only 4 pins.
Step 2: Schematics
the connection for this module is very easy .
for Transmitter :
Vcc >>>>5V
ATAD>>>D4"You can change it as you like from Software" .
Gnd >>> Gnd
Receiver :
Vcc>>>>5V
Data>>>D2
Gnd>>>Gnd
joystick:-
Vcc>>>>5V
Gnd>>>Gnd
X>>>A0
Y>>>A1
Key>>>D2"Connect this to arduino only if you need to use this"
L293D:-
10>>>D6
15>>>D5
2>>>D9
7>>>D10
1,8,9,16>>>5V
4,5,12,13>>>GND
11,14>>>Motor A
3,6>>>Motor B
Step 3: Code
Just copy this code to your Arduino IDE. You have to copy the code of transmitter in one Aduino program and of reciever to another program.
The code of transmitter will be uploaded to that arduino on which joystick is interfaced and the code of reciever will be connected to the arduino on the bot.
Transmitter Code:-
(NOTE:-
- First calibrate your joystick using serial monitor to get your joystick respective values).
- AS I have to send 4 data bits i have used 4 legs of transmitter to send 4 bits instead one data bit that is shown in schematics)
void setup() {
// put your setup code here, to run once:
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
// Serial.begin(9600);
}
void loop() {
int a = analogRead(A0);
int b = analogRead(A1);
// Serial.print(a);
// Serial.print("\\\\");
// Serial.println(b);
if (b >= 700 && b < 1023 && a >= 500 && a <= 540 ) {
digitalWrite(5, 0); // FORWARD
digitalWrite(6, 1);
digitalWrite(9, 0);
digitalWrite(10, 1);
}
if (b < 200 && a >= 500 && a <= 540 ) {
digitalWrite(5, 1); // REVERSE
digitalWrite(6, 0);
digitalWrite(9, 1);
digitalWrite(10, 0);
}
if (a >= 700 && a < 1023 && b >= 500 && b <= 540 ) {
digitalWrite(5, 0); // right
digitalWrite(6, 1);
digitalWrite(9, 1);
digitalWrite(10, 0);
}
if (a < 200 && b >= 500 && b <= 540 ) {
digitalWrite(5, 1); // left
digitalWrite(6, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
}
if (a >= 500 && a <= 540 && b >= 500 && b <= 540 ) {
digitalWrite(5, 0); // stop
digitalWrite(6, 0);
digitalWrite(9, 0);
digitalWrite(10, 0);
}
}
Reciever Code:-
(NOTE:- As I have to recieve 4 data bits i have used 4 legs of reciever instead of one data bit as shown in schematic.
void setup() {
// put your setup code here, to run once:
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
int a, b, c, d;
a = digitalRead (9);
b = digitalRead (10);
c = digitalRead (11);
d = digitalRead (12);
if (a == 0 && b == 1 && c == 0 && d == 1) {
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(9, 1);
digitalWrite(10, 0);
}
if (a == 1 && b == 0 && c == 1 && d == 0) {
digitalWrite(5, 0);
digitalWrite(6, 1);
digitalWrite(9, 0);
digitalWrite(10, 1);
}
if (a == 0 && b == 1 && c == 1 && d == 0) {
digitalWrite(5, 0);
digitalWrite(6, 1);
digitalWrite(9, 1);
digitalWrite(10, 0);
}
if (a == 1 && b == 0 && c == 0 && d == 1) {
digitalWrite(5, 1);
digitalWrite(6, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
}
if (a == 0 && b == 0 && c == 0 && d == 0) {
digitalWrite(5, 0);
digitalWrite(6, 0);
digitalWrite(9, 0);
digitalWrite(10, 0);
}
}
Participated in the
Arduino Contest 2017
Participated in the
Remote Control Contest 2017