Arduino UNO-Based RC Controlled Brushless Motor and Servo System
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a brushless motor and multiple servos using an Arduino UNO microcontroller. The circuit includes an Electronic Speed Controller (ESC) for the motor, a 6-channel RC receiver for remote control, and an Adafruit Proto Shield for easy prototyping. The power is supplied by an 11.1V 3S LiPo battery. The Arduino UNO reads signals from the RC receiver and controls the ESC and servos accordingly.
Component List
11.1V 3S Battery LiPo 40C 2250mAh
- Description: Provides power to the circuit.
- Pins: Battery Positive, Battery Ground
Arduino UNO
- Description: Microcontroller used to control the ESC and servos based on input from the RC receiver.
- 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
Electronic Speed Controller (ESC)
- Description: Controls the speed of the brushless motor.
- Pins: Battery VCC, Battery GND, Signal, 5v out, GND out, M1, M2, M3
Brushless Motor
- Description: Motor controlled by the ESC.
- Pins: L1, L2, L3
Adafruit Proto Shield R3
- Description: Prototyping shield for Arduino UNO.
- Pins: 1, P$5, P$6, GND, VIN, +5V, 3.3V, RESET, IOREF, NC, D0, D1, D2, D3, D4, D5, D6, D7, A0, A1, A2, A3, A4, A5, AREF, D8, D9, D10, D11, D12, D13, MISO, MOSI, SCK, SCL, SDA, and many more.
RC Receiver 6 Channels
- Description: Receives signals from the remote control.
- Pins: CH1, VCC, GND, CH2, CH3, CH4, CH5, CH6, Bind
Servo
- Description: Actuators controlled by PWM signals.
- Pins: GND, VCC, PWM
Wiring Details
11.1V 3S Battery LiPo 40C 2250mAh
- Battery Positive connected to Battery VCC of the Electronic Speed Controller (ESC).
- Battery Ground connected to Battery GND of the Electronic Speed Controller (ESC).
Arduino UNO
- D11 connected to Signal of the Electronic Speed Controller (ESC).
- D3 connected to CH1 of the RC Receiver.
- D4 connected to PWM of the first Servo.
- D5 connected to CH2 of the RC Receiver.
- D6 connected to CH3 of the RC Receiver.
- D7 connected to PWM of the second Servo.
- D9 connected to CH4 of the RC Receiver.
- D10 connected to CH5 of the RC Receiver.
- D12 connected to PWM of the third Servo.
Electronic Speed Controller (ESC)
- Battery VCC connected to Battery Positive of the 11.1V 3S Battery LiPo.
- Battery GND connected to Battery Ground of the 11.1V 3S Battery LiPo.
- Signal connected to D11 of the Adafruit Proto Shield R3.
- 5v out connected to +5V of the Adafruit Proto Shield R3.
- GND out connected to GND of the Adafruit Proto Shield R3.
Brushless Motor
- L1, L2, L3 connected to M1, M2, M3 of the Electronic Speed Controller (ESC).
Adafruit Proto Shield R3
- +5V connected to VCC of the RC Receiver.
- GND connected to GND of the RC Receiver.
- D11 connected to Signal of the Electronic Speed Controller (ESC).
- D3 connected to CH1 of the RC Receiver.
- D4 connected to PWM of the first Servo.
- D5 connected to CH2 of the RC Receiver.
- D6 connected to CH3 of the RC Receiver.
- D7 connected to PWM of the second Servo.
- D9 connected to CH4 of the RC Receiver.
- D10 connected to CH5 of the RC Receiver.
- D12 connected to PWM of the third Servo.
- +5V connected to VCC of all three Servos.
- GND connected to GND of all three Servos.
RC Receiver 6 Channels
- VCC connected to +5V of the Adafruit Proto Shield R3.
- GND connected to GND of the Adafruit Proto Shield R3.
- CH1 connected to D3 of the Adafruit Proto Shield R3.
- CH2 connected to D5 of the Adafruit Proto Shield R3.
- CH3 connected to D6 of the Adafruit Proto Shield R3.
- CH4 connected to D9 of the Adafruit Proto Shield R3.
- CH5 connected to D10 of the Adafruit Proto Shield R3.
Servo
First Servo:
- PWM connected to D4 of the Adafruit Proto Shield R3.
- VCC connected to +5V of the Adafruit Proto Shield R3.
- GND connected to GND of the Adafruit Proto Shield R3.
Second Servo:
- PWM connected to D7 of the Adafruit Proto Shield R3.
- VCC connected to +5V of the Adafruit Proto Shield R3.
- GND connected to GND of the Adafruit Proto Shield R3.
Third Servo:
- PWM connected to D12 of the Adafruit Proto Shield R3.
- VCC connected to +5V of the Adafruit Proto Shield R3.
- GND connected to GND of the Adafruit Proto Shield R3.
Code Documentation
#include <Servo.h>
unsigned long previous_millis = 0;
int interval = 10;
#define CH1 3
#define CH2 5
#define CH3 6
#define CH4 9
#define CH5 10
#define Servo1 7
#define Servo2 12
#define Servo3 4
// Read the number of a given channel and convert to the range provided.
// If the channel is off, return the default value
int readChannel(int channelInput, int minLimit, int maxLimit, int defaultValue){
int ch = pulseIn(channelInput, HIGH, 30000);
if (ch < 100) return defaultValue;
return map(ch, 1000, 2000, minLimit, maxLimit);
}
// Red the channel and return a boolean value
bool redSwitch(byte channelInput, bool defaultValue){
int intDefaultValue = (defaultValue)? 100: 0;
int ch = readChannel(channelInput, 0, 100, intDefaultValue);
return (ch > 50);
}
Servo ESC;
Servo serv1;
Servo serv2_pitch_r;
Servo serv3_pitch_l;
void setup(){
Serial.begin(9600);
serv1.attach(Servo1);
serv2_pitch_r.attach(Servo2);
serv3_pitch_l.attach(Servo3);
ESC.attach(11,1000,2000);
pinMode(CH1, INPUT);
pinMode(CH2, INPUT);
pinMode(CH3, INPUT);
pinMode(CH4, INPUT);
pinMode(CH5, INPUT);
pinMode(2, OUTPUT);
}
int ch1Value, ch2Value, ch3Value, ch4Value;
bool ch5Value;
void loop() {
unsigned long current_millis = millis();
if(current_millis - previous_millis > interval) {
ch1Value = readChannel(CH1, -100, 100, 0);
ch2Value = readChannel(CH2, -100, 100, 0);
ch3Value = readChannel(CH3, -100, 100, -100);
ch4Value = readChannel(CH4, -100, 100, 0);
ch5Value = redSwitch(CH5, false);
int escvel = map(ch3Value,-