Introduction: Arduino Game Controller Using Bluetooth
This project involves creating a remote control system using an Arduino, an HC-06 (or HC-05) Bluetooth module, and two servo motors. The system can be used to control games like Beach Buggy Racing, providing an easy and intuitive way to play without using traditional buttons.
Supplies
The Main component is the TV Remote
- Arduino (Uno or Nano) - 1
- Bluetooth Module (HC-05 or HC-06) - 1 *I'm using an HC-06 Bluetooth module
- Servo Motors - 2
- Power Supply (18650 Battery - 2 or a Power Bank) *I'm using a power bank in this project
- Jumper Wires - (Male to Male - 6) and (Male to Female - 4)
- Thick wood pieces - 2
- Foam Pieces to design the base
- An Android phone with Arduino Bluetooth RC Car app for control (*Note: Apple Phones does not support HC-05 and HC-06 Bluetooth Connections)
Step 1: Wiring the Components
Connect the male to male jumper wires to both the Servo motors
Connect the male to female jumper wires to the HC-05 or HC-06 Bluetooth module
Step 2: Wiring the Servo Motors:
- Connect the signal pin of the first servo motor to Arduino pin 9.
- Connect the signal pin of the second servo motor to Arduino pin 10.
- Connect the power and ground pins of the servos to the Arduino's 5V and GND pins.
Step 3: Wiring the HC-05 (or HC-06)
- Connect VCC to the 5V pin on the Arduino.
- Connect GND to the GND pin on the Arduino.
- Connect TXD to the RX pin on the Arduino.
- Connect RXD to the TX pin on the Arduino.
Step 4: Upload the Code
#include <Servo.h>
Servo leftServo; // Create a Servo object for the left servo
Servo rightServo; // Create a Servo object for the right servo
int leftServoPin = 9; // Pin for the left servo
int rightServoPin = 10; // Pin for the right servo
char command; // Variable to store the incoming command from the HC-05
void setup() {
leftServo.attach(leftServoPin); // Attach the left servo to pin 9
rightServo.attach(rightServoPin); // Attach the right servo to pin 10
leftServo.write(90); // Initialize the left servo to the neutral position (90 degrees)
rightServo.write(90); // Initialize the right servo to the neutral position (90 degrees)
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
if (Serial.available() > 0) {
command = Serial.read(); // Read the incoming command from the HC-05
}
// Continuous checking for the command
if (command == 'R') { // If the left button is pressed
leftServo.write(0); // Move to 0 degrees
} else {
leftServo.write(45); // Return to the neutral position when the button is released
}
if (command == 'L') { // If the right button is pressed
rightServo.write(180); // Move to 180 degrees
} else {
rightServo.write(135); // Return to the neutral position when the button is released
}
}
Step 5: Check Both Servo Motors
The Servo motor movement should work like the above video
Step 6: Design the Base
You can design the base of how you'd want it to be as the size of your remote is totally different to mine but the most important part is that both Servo motors have to press the button on the remote
Step 7: Testing
- Power the Arduino Uno
- Place the Remote and make sure both Servo motors touches the buttons of the remote
- Then Install the app using this link https://play.google.com/store/apps/details?id=omfaer.com.carino&hl=en
- Then using the app, connect the HC-06 (or HC-05) Bluetooth module
Then Enjoy your game!!!