Arduino Two-way Bluetooth Hovercraft

by Joshuar9202 in Circuits > Arduino

724 Views, 5 Favorites, 0 Comments

Arduino Two-way Bluetooth Hovercraft

processed-943a08ff-ec40-4ab8-92c5-2c006c8bb7f8_MW9s5ajB.jpeg
Screenshot 2022-08-09 202019.png

I made a two-way Bluetooth hovercraft to demonstrate the use of two-way Bluetooth communication with Arduino. Many projects use Bluetooth, but that form of Bluetooth communication requires another device. I wanted to make my own controller for my project, and that is achievable by using two-way Bluetooth and making a receiver and a controller. The hovercraft works with one brushless motor to control lift and thrust and one servo motor to channel the air at an angle to turn.

Supplies

Two Bluetooth HC05 modules are required for communication

One brushless motor with propeller and ESC are required for thrust and lift

One servo motor is required for directional control

Cardboard or other lightweight material for making the base

A plastic bag for making the skirt

Thin plastic sheet for making the rudder (is found in clear plastic spinach boxes)

Disposable drinking straws to send air to the front of the vehicle

One joystick for the controller

11.1v lithium polymer battery for powering the brushless motor (be very careful with the battery)

various wires and a breadboard for connections

resistors (10k)

And finally, two Arduinos for the controller and hovercraft

Building the Hovercraft

processed-48096b24-2f91-44f2-8b7d-33bc4a357be6_Hg8Ffeb5.jpeg
processed-dcc0ab47-d5cf-4e70-ac31-bdfa92a3d2ae_uilhVfCv.jpeg
20220808_212855.jpg

Build the base by using the cardboard as a platform. Then make some ducts to channel air into the bottom of the vehicle. Make two of them and place them about a centimeter away from the back of the craft and leave space in between the two ducts for the servo motor. To make the rudder for the servo, I cut a sheet of plastic out from a spinach box and folded it into a triangular prism. The reason for making the rudder a triangle shape is that it will be easier to control since the angle that the air hits the rudder is greater. In the ducts, I also used some disposable drinking straws to channel the air to the front too. To make the skirt, I used a plastic bag and cut an outline of the base with about an inch hanging off. Then I made a frame of the base that was about an inch wide and taped the skirt to there. Then I attached the frame to the hovercraft base. To let the air out, I cut a central hole and then taped the sides to the base to maintain pressure in the craft. Then to make the motor mount use a small wood block and drill some holes for the brushless motor. I used rubber bands to attach the wood block to a Lego frame and then built the rest of the base until it was sturdy. I also used some black pins to anchor it into the cardboard. I also used the Lego panels to anchor the Arduino board and the ESC. The ESC (Electronic Speed Controller) is required because the brushless motor works by powering on electromagnets in a certain sequence and the ESC is capable of sending those signals to the motor. Also, the brushless motor requires a large power supply, so I used a 11.1v Li-Po battery.

The connections are as follows for the HC-05:

Vcc --> 5v

Gnd --> Gnd

Rx --> Tx (on the Arduino)

Tx --> Rx (on the Arduino)

The connections are as follows for the ESC:

Brown --> Gnd

Red --> 5v

Yellow (Signal) --> Digital pin 9

The connections are the same for the Servo motor, but the Signal pin has to be another digital pin on the Arduino. I used D10

The HC-05 uses the Tx (transmitter) and Rx (Receiver) are used to communicate with the master and receive the values.

Building the Controller

20220808_211554.jpg
20220808_211646.jpg
20220808_211629.jpg

the controller just consists of the joystick and the bluetooth module. The Arduino will just take the input from the joystick and the HC-05 will send the signal to the hovercraft.

The connections for the HC-05:

5V --> 5V

Gnd --> Gnd

Tx --> Rx

Rx --> Tx (through a 10k resistor)

Rx --> Gnd (through a 10k resistor)

The connections for the joystick:

Vcc --> 5v

Xout --> A0

Yout --> A1

Gnd --> Gnd

And that's it for the building portions.

Pairing Bluetooth Modules

For the Bluetooth modules to be able to communicate with each other, they have to be paired. To do this we have to enter the AT command mode for the Bluetooth module. To do this, hold the small button on the HC-05 and power on the module. You know you have done this successfully when the LED starts blinking approximately every 2 seconds. Then, upload an empty sketch to the Arduino and open the serial monitor. Make sure both NL and CR is selected as well as 38400 baud rate. Type "AT" into the serial monitor to see if you successfully entered AT mode. You should get back a message of OK. To set this module as the master, (because the default mode is slave) you have to type "AT+ROLE = 1" and then to connect the module to the slave, some might try and get the address of the slave module and connect it that way, but I find it easier to use "AT+CMODE=1" because it will just connect to any device that is ready to be paired. Also use "AT+UART?" to see the baud rate and make sure that both the modules are operating at 38400. Then when connected again in normal mode, the Bluetooth modules should connect after a few seconds and the slave will be a steady LED and the master will flash every 2 seconds.

Coding

Master code:

Starts out by declaring a variable to hold the value that comes out of the serial communication of the Bluetooth modules. I assign this variable to be called state. Next, we declare xValue and yValue to hold the joystick positions as a variable. In the setup section all we have to do is start the Serial communication at 38400 which is the default for Bluetooth modules. In the loop, first we have to create an if statement asking whether the two Bluetooth modules are communicating. If they are, then it will read the serial monitor and assign it to our variable, state. Then we read the values of the joystick and then map them into 0 to 180 rather than 0 to 1023. We do this for both x and y. I did this because the ESC and servo motors both run from 0 to 180 so it makes it a bit easier to understand. Finally, we write the if statements to send commands. If the joystick points right, it will send the character 'r' to the other Bluetooth module using the Serial.write() function. We do this three more times to print 'l' when pointing left, 'f' when up, and 's' when the joystick is not in any of those conditions so that the hovercraft will stop.

Slave code (hovercraft):

First, we include the servo library because the servo motor needs it and the brushless motor is actually controlled as if it were a servo motor. Then we declare the ESC and Rudder as servo motors. Then we have the same variable state to hold the values from the serial monitor. In the setup section, first we declare the ESC is in pin 9 and we write the minimum and maximum pulse widths in microseconds. We also have to declare the rudder in pin 10 and set the rudder to be at 90 degrees so it can turn both ways to turn left and right because you can't use negative values while coding the servo motor. We also start the serial monitor at 38400. In the loop section, we check if the serial monitor is receiving data and if so, assign the variable state to whatever data is being sent. Then if state is equal to 'f', the ESC will start at 35, and the rudder will stay at 90 to stay straight. Likewise, if state is equal to 'l' the ESC will stay at 35 and the rudder will go to 65 degrees to turn left and the same for 'r', but the rudder will go to 115 degrees to turn right. The last condition is if it is equal to 's' and then everything will go to its default position with the ESC at 0 and the rudder at 90 degrees.