How to use a RC transmitter and receiver with your arduino (Robot, Drone)

This tutorial will show you how to use a Radio Control transmitter and Receiver with your arduino to control Robots, Drones, Security Cameras and more… I will also show you how to control the speed and direction of a DC motor with your RC radio and receiver.

click on video below for full tutorial!

Check us out on Facebook!

PARTS LIST:

#affiliate links#

RC Radio & Receiver

ARDUINO Board

H bridge  (L298N)

Servo

DC motor

Jumper Wires

ARDUINO SKETCH:

#include <Servo.h>
Servo servo1;
#define rc1 9 // receiver chanel 1 on pin 9
#define rc2 10 // receiver chanel 2 on pin 10
#define spd 5 // PWM pin on L298N
#define pin1 4 // in 1 pin on L298N to pin 4 on ARDUINO
#define pin2 3 // in 2 pin on L298N to pin 3 on ARDUINO
int ch1; // value of chanel 1 of the receiver
int ch2; // value of chanel 2 of the receiver
int val1; // servo position
int val2; // motor speed

void setup() {
servo1.attach(11);
pinMode (rc1, INPUT);
pinMode (rc2, INPUT);
pinMode (spd, OUTPUT);
pinMode (pin1, OUTPUT);
pinMode (pin2, OUTPUT);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
Serial.begin(9600); // for testing
}

void loop() {
ch1 = pulseIn(rc1, HIGH);
ch2 = pulseIn(rc2, HIGH);
Serial.print(“ch1 “);
Serial.println(ch1);
Serial.print(“ch2 “);
Serial.println(ch2);
val1 = map(ch2, 1100, 1900, 10, 170);
servo1.write(val1);

if (ch1 < 1450)
{
val2 = map(ch1, 1450, 1900, 255, 25);
analogWrite(spd, val2);
digitalWrite(pin2, LOW);
digitalWrite(pin1, HIGH);
}
else if (ch1 > 1550)
{
val2 = map(ch1, 1550, 1100, 255, 25);
analogWrite(spd, val2);
digitalWrite(pin1, LOW);
digitalWrite(pin2, HIGH);
}
else if (ch1 == 0)
{
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
}

delay(100);
}