Use your smartphone to control an airboat

Putting It All Together

The three fans are wired to pins 6 and 7, 8 and 9, and 10 and 11. During construction, make sure the Arduino and battery pack are balanced in the container to keep everything – the fan blades, Arduino, and battery pack – out of the water (Figure 7).

Figure 7: The fan blades on the airboat stay out of the water when the computer assembly is balanced correctly.

The code in Listing 3 is the final program that controls the airboat. The first section sets up the Bluetooth module and describes the fans by specifying how they are pinned into the Arduino, defining them as outputs, and turning them all off. The main loop then accepts input from the smartphone and turns the fans on and off as commanded.

Listing 3

airboat.ino

01 // Airboat with 3 fans controlled by a bluetooth phone
02
03 int INA1 = 6;  // back fan
04 int INB1 = 7;  // back fan
05 int INA2 = 8;  // right side fan
06 int INB2 = 9;  // right side fan
07 int INA3 = 10; // left side fan
08 int INB3 = 11; // left side fan
09
10 char thekey;  // input from Bluetooth phone
11
12 void setup()
13 {
14   // initialize the serial communication:
15   Serial.begin(9600); //baud rate of Bluetooth Module
16   // define the pins of the 3 fans as outputs
17   pinMode(INA1,OUTPUT);
18   pinMode(INB1,OUTPUT);
19   pinMode(INA2,OUTPUT);
20   pinMode(INB2,OUTPUT);
21   pinMode(INA3,OUTPUT);
22   pinMode(INB3,OUTPUT);
23   // start with all fans turned off
24   digitalWrite(INA1,LOW);
25   digitalWrite(INB1,LOW);
26   digitalWrite(INA2,LOW);
27   digitalWrite(INB2,LOW);
28   digitalWrite(INA3,LOW);
29   digitalWrite(INB3,LOW);
30 }
31
32 void loop() {
33
34   if (Serial.available() > 0) {
35     thekey = Serial.read(); // get the key from the phone
36
37     //  "s" stops all fans
38     if (thekey == 's') {
39       Serial.println("Fans are stopped");
40       digitalWrite(INB1,LOW);
41       digitalWrite(INB2,LOW);
42       digitalWrite(INB3,LOW);
43       delay(1500);
44     }
45     //  "g" runs all fans
46     if (thekey == 'g') {
47       Serial.println("Fans are going");
48       digitalWrite(INB1,HIGH);
49       digitalWrite(INB2,HIGH);
50       digitalWrite(INB3,HIGH);
51     }
52     //  "l" only run right fan, turn left
53     if (thekey == 'l') {
54       Serial.println("Turn left");
55       digitalWrite(INB1,LOW);
56       digitalWrite(INB2,HIGH);
57       digitalWrite(INB3,LOW);
58     }
59     // "r" only run left fan, turn right
60     if (thekey == 'r') {
61       Serial.println("Turn right");
62       digitalWrite(INB1,LOW);
63       digitalWrite(INB2,LOW);
64       digitalWrite(INB3,HIGH);
65     }
66    }
67 }

Summary

With three fan modules, the airboat moves quite well (Figure 8), although two fans also work. Some possible future enhancements could be:

  • trying to connect four or five fans,
  • creating an Android app in App Inventor to control the airboat,
  • adding a rudder with a servomotor controller, and
  • creating a waterproof case for the Arduino and battery.
Figure 8: The airboat in action.

Good luck building your own smartphone-controlled airboat.

The Author

Brooke and Leah Metcalfe are 12-year-old twins who live in Burlington, Canada. When they aren't doing computer projects with their dad, they like swimming, paddle boarding, and skiing.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content