Arduino UNO and PCA9685 Controlled Robotic Arm with Bluetooth and Audio Feedback
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control multiple servos, DC motors, and a DFPlayer Mini module using an Arduino UNO. The circuit also includes a Bluetooth module for wireless communication. The Adafruit PCA9685 PWM Servo Breakout is used to control the servos, while the L298N DC motor driver is used to control the DC motors. The DFPlayer Mini is used to play audio files, and a loudspeaker is connected to it for sound output. The circuit is powered by two 9V batteries.
Component List
Adafruit PCA9685 PWM Servo Breakout
- Description: 16-channel PWM driver
- Pins: 5.0V, GND, PWRIN, PWM0-PWM15, VCC, SDA, SCL, OE
Servo
- Description: Standard servo motor
- Pins: GND, VCC, PWM
Arduino UNO
- Description: Microcontroller board
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
9V Battery
- Description: Power source
- Pins: +, -
DC Motor
- Description: Standard DC motor
- Pins: pin 1, pin 2
L298N DC Motor Driver
- Description: Dual H-Bridge motor driver
- Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
DFPlayer MINI
- Description: MP3 player module
- Pins: VCC, BUSY, RX, USB -, TX, USB +, DAC_R, K2/ADC_KEY, DAC_L, K1/ADC_KEY, SPK1, IO 2, GND, SPK2, IO 1
HC-05 Bluetooth Module
- Description: Bluetooth communication module
- Pins: Key, VCC, GND, TXD, RXD, State
Loudspeaker
- Description: Standard loudspeaker
- Pins: pin1, pin2
Wiring Details
Adafruit PCA9685 PWM Servo Breakout
- PWRIN connected to + of 9V Battery
- GND connected to - of 9V Battery
- 5.0V connected to:
- VCC of Servo (multiple)
- 5V of Arduino UNO
- GND connected to:
- GND of Servo (multiple)
- GND of Arduino UNO
- PWM0 connected to PWM of Servo
- PWM1 connected to PWM of Servo
- PWM2 connected to PWM of Servo
- PWM3 connected to PWM of Servo
- PWM4 connected to PWM of Servo
- PWM5 connected to PWM of Servo
- PWM6 connected to PWM of Servo
- PWM7 connected to PWM of Servo
- PWM8 connected to PWM of Servo
- PWM9 connected to PWM of Servo
- SDA connected to A4 of Arduino UNO
- SCL connected to A5 of Arduino UNO
Servo
- GND connected to GND of Adafruit PCA9685 PWM Servo Breakout
- VCC connected to 5.0V of Adafruit PCA9685 PWM Servo Breakout
- PWM connected to PWM pins of Adafruit PCA9685 PWM Servo Breakout (PWM0-PWM9)
Arduino UNO
- 5V connected to VCC of Adafruit PCA9685 PWM Servo Breakout
- GND connected to GND of Adafruit PCA9685 PWM Servo Breakout
- A4 connected to SDA of Adafruit PCA9685 PWM Servo Breakout
- A5 connected to SCL of Adafruit PCA9685 PWM Servo Breakout
- 3.3V connected to VCC of HC-05 Bluetooth Module
- GND connected to:
- GND of L298N DC Motor Driver
- GND of DFPlayer MINI
- GND of HC-05 Bluetooth Module
-
- of 9V Battery
- D9 connected to RX of DFPlayer MINI
- D8 connected to TX of DFPlayer MINI
- D7 connected to ENB of L298N DC Motor Driver
- D6 connected to IN4 of L298N DC Motor Driver
- D5 connected to IN3 of L298N DC Motor Driver
- D4 connected to IN2 of L298N DC Motor Driver
- D3 connected to IN1 of L298N DC Motor Driver
- D2 connected to ENA of L298N DC Motor Driver
- D1 connected to RXD of HC-05 Bluetooth Module
- D0 connected to TXD of HC-05 Bluetooth Module
9V Battery
- + connected to PWRIN of Adafruit PCA9685 PWM Servo Breakout
- - connected to GND of Adafruit PCA9685 PWM Servo Breakout
DC Motor
- pin 1 connected to OUT3 of L298N DC Motor Driver
- pin 2 connected to OUT4 of L298N DC Motor Driver
- pin 1 connected to OUT1 of L298N DC Motor Driver
- pin 2 connected to OUT2 of L298N DC Motor Driver
L298N DC Motor Driver
- 12V connected to + of 9V Battery
- 5V connected to VCC of DFPlayer MINI
- OUT1 connected to pin 1 of DC Motor
- OUT2 connected to pin 2 of DC Motor
- OUT3 connected to pin 1 of DC Motor
- OUT4 connected to pin 2 of DC Motor
- GND connected to GND of Arduino UNO
- ENA connected to D2 of Arduino UNO
- IN1 connected to D3 of Arduino UNO
- IN2 connected to D4 of Arduino UNO
- IN3 connected to D5 of Arduino UNO
- IN4 connected to D6 of Arduino UNO
- ENB connected to D7 of Arduino UNO
DFPlayer MINI
- VCC connected to 5V of L298N DC Motor Driver
- GND connected to GND of Arduino UNO
- RX connected to D9 of Arduino UNO
- TX connected to D8 of Arduino UNO
- SPK1 connected to pin2 of Loudspeaker
- GND connected to pin1 of Loudspeaker
HC-05 Bluetooth Module
- VCC connected to 3.3V of Arduino UNO
- GND connected to GND of Arduino UNO
- RXD connected to D1 of Arduino UNO
- TXD connected to D0 of Arduino UNO
Loudspeaker
- pin1 connected to GND of DFPlayer MINI
- pin2 connected to SPK1 of DFPlayer MINI
Documented Code
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <SoftwareSerial.h>
#include "DFRobotDFPlayerMini.h"
#define SERVOMIN 150 // Valor mínimo para el pulso del servo (0°)
#define SERVOMAX 600 // Valor máximo para el pulso del servo (180°)
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
SoftwareSerial BT(10, 11); // RX, TX (Conecta HC-05 a estos pines)
SoftwareSerial DFPlayerSerial(8, 9); // TX, RX (Conecta DFPlayer Mini a estos pines)
DFRobotDFPlayerMini myDFPlayer;
const int motor1_IN1 = 3;
const int motor1_IN2 = 4;
const int motor1_ENA = 2;
const int motor2_IN3 = 5;
const int motor2_IN4 = 6;
const int motor2_ENB = 7;
int velocidadMotor = 128; // Velocidad de los motores DC (media)
int velocidad180 = 90; // Para servos de 0 a 180 grados
int velocidad90 = 45; // Para servos de 0 a 90 grados
int velocidad135 = 67; // Para servos de 0 a 135 grados
bool motor1Controlado = false; // Estado del botón para motor 1
bool motor2Controlado = false; // Estado del botón para motor 2
bool motor1Sentido = true; // Sentido del motor 1 (por defecto sentido "x")
bool motor2Sentido = true