Introduction: DIY Arduino Catamaran

This Instructable will teach you how to build your own remote controlled boat (in this case a catamaran) using the Arduino single board micro-controller, some code, and scrap materials that are easily available.

Step 1: Building the Remote Control (Materials)

The following materials are needed:

  • RF Transmitter and Receiver
  • 9V battery and contact
  • Arduino-based microcontroller
  • Gauge 22 solid wire or connectors
  • Solderless breadboard
  • 2 buttons
  • 2 potentiometers (preferably 1 kilo ohm)
  • 2 100 ohm resistors
  • 2 1 kilo ohm resistors

Step 2: Building the Remote Control (Transmission Circuit)

First and foremost, this device needs to send the data! Connect the RF transmitter before anything else. Note that an Alexan AM Radio transmitter and Receiver pair was used for this project.

  1. Solder headers to RF transmitter, if necessary.
  2. Install on solderless breadboard, and connect appropriate ground (GND) and input voltage (VCC or VIN) pins to the ground and power strips, respectively.
  3. Connect the ground strip of the breadboard to the GND pin of the Arduino. An external power source may be used. If so, connect the power and ground wires of the 9V battery contact to the power and ground strips of the solderless breadboard, respectively. Otherwise, simply connect the 5V pin on the Arduino to the power strip.
  4. Connect the Tx Serial port (transmission port) of the Arduino to the Data Input port of the RF module.
  5. Connect an antenna - in this case, any metal wire of length equal to the wavelength of your transmitter (check the data sheet for details) divided by any power of two - to the RFOUT pin of your transmitter.

Step 3: Building the Remote Control (Data Input Circuit)

Two forms of data input will be used - movement control, which will be handled with buttons, and speed control, which will be handled with potentiometers.

  1. Install two buttons on the solderless breadboard in a circuit as shown below. Connect an Arduino digital pin in parallel to the resistor in each circuit, as shown below. This will allow the pin to read the state of this circuit.
  2. Install two potentiometers, in a circuit as shown below. Note that the middle pin of the potentiometer is the output voltage, while the outer pins are for ground and voltage, respectively.
  3. Connect an Arduino analog pin to to the potentiometer output, in a circuit as shown below. This will allow the pin to read the voltage of this circuit.

This setup is sufficient to serve as a remote control for the RC boat! However, if you like, you make a casing or mount to make pushing the buttons and manipulating the potentiometers easier.

Step 4: Building the Remote Control (Coding)

The code must be able to handle the following processes:

  • Constantly read data from the input circuits.
  • Generate a string or character array consisting of commands to be executed by the boat based on this data.
  • Send the data string or character array over radio frequency using the serial ports (as an interface to the module). Ensure the integrity of the data string (use checking characters).

Step 5: Building the Remote Control (Actual Code)

#include //for the convenience of placing the serial ports wherever we want

SoftwareSerial rfOut(10,11); //10 rx, 11 tx String output = ""; int val = 0; bool transmitleft = false; bool transmitright = false;

int lspeed = 128; int rspeed = 128;

char baper[20]; //a buffer of characters to hold data to be sent void setup() { pinMode(2, INPUT); //input from the first button pinMode(3, INPUT); //input from the second button rfOut.begin(4800); Serial.begin(9600); }

void loop() { rfOut.flush(); //to ensure that the serial port’s stream is empty. buttonRead(); //read data from potentiometers rspeed = (analogRead(4)*256/1024); lspeed = (analogRead(5)*256/1024);

delay(5); //send data according to data read if(transmitright&&transmitleft){ sprintf(baper, "$BTH%3d%3d*", lspeed, rspeed); rfOut.print(baper); }else if(transmitleft){ sprintf(baper, "$LFT%3d%3d*",lspeed,000); rfOut.print(baper); }else if (transmitright){ sprintf(baper, "$RGT%3d%3d*",000,rspeed); rfOut.print(baper); }else{ rfOut.print("$STP*"); } }

void buttonRead(){ if(digitalRead(2)){ transmitleft = true; }else{ transmitleft = false; } if(digitalRead(3)){ transmitright = true; }else{ transmitright = false; } }

Step 6: Building the Boat (Materials)

You will need:

  • RF receiver
  • Gauge 22 wire or connectors
  • 2 DC motors (preferably 6V)
  • 2 NPN transistors (preferably 2N 3904 BJT transistors)
  • 2 100 ohm resistors
  • 9V battery and contact

Step 7: Building the Boat (Reception Circuit)

The boat needs to receive data being sent by the remote control. To do this, we have to set up a receiver circuit which can interpret the radio signal transmitted and send it to the Arduino as serial data.

  1. Install the RF receiver on a solderless breadboard, in a circuit as shown below.
  2. Connect an antenna - in this case, any metal wire of length equal to the wavelength of your transmitter (check the data sheet for details) divided by any power of two - to the RFIN pin of your receiver.
  3. Connect the DATA OUT pin to the Rx serial port of your Arduino.

Step 8: Building the Boat (Motor Circuit)

The current draw of the DC motors used by this project is too large for the Arduino’s 5V pin to handle. That’s why we’ll be using an external power source, controlled using NPN transistors.

  1. Connect the transistors and motors in a circuit as shown below.
  2. Connect the base of each transistor to an Arduino digital pin capable of PWM (pulse with modulation). The base is the pin used to control a transistor as a “gate” for a circuit. Using a PWN pin will allow the circuit to apply different levels of voltage between “HIGH” and “LOW”, and therefore, different speeds to the motors, based on the input from the remote control.
  3. Connect the GND pin of the Arduino to the ground strip of the circuit. Do NOT connect the Arduino 5V pin to the power strip of the circuit.
  4. Connect the power and ground wires of the 9V battery contact to the power and ground strips of the solderless breadboard, respectively.

Step 9: Building the Boat (Coding)

The code must be able to accomplish the following:

  • Constantly read data from the receiver via serial port.
  • Interpret incoming data and check for data integrity characters.
  • Generate a current through the motor circuit based on commands sent by the remote control.

Step 10: Building the Boat (Actual Code)

#include

#include //data input variables SoftwareSerial rfIn(10,11); //10 rx, 11 tx char buffer[20]; //these buffers are for separating the contents of the input string char in[20]; //this stores the movement TYPE char in2[20]; //this stores the speed of the left motor, if available. char in3[20]; //this stores the speed of the right motor, if available. char c; //input character storage byte i; //counter for string reading byte j = 0; //counter for string output //movement: motor groups boolean left = false; boolean right = false; //movement: motor speeds int lspeed = 0; int rspeed = 0; //other int time = 0; //motors int lmotor = 3; int rmotor = 6; void setup() { Serial.begin(9600); rfIn.begin(4800); pinMode(lmotor, OUTPUT); pinMode(rmotor, OUTPUT); }

void loop() { feed(); respond(); act(lspeed, rspeed); }

void findNumber(char input[], char output[], char output2[], char output3[]){ char c; byte i = 0; byte j = 0; while(i < 3){ output[i] = input[i]; i++; } //start of speed data is now known in i while(j < 3){ output2[j] = input[i]; i++; j++; } j = 0; while(j < 3){ output3[j]= input[i]; i++; j++; } }

void respond(){ //convention: in2 will be lspeed, in3 is rspeed. findNumber(buffer, in, in2, in3);

if(strcmp(in, "LFT") == 0){ left = true; right = false; lspeed = toInteger(in2); } if(strcmp(in, "RGT") == 0){ left = false; right = true; rspeed = toInteger(in3); } if(strcmp(in, "BTH") == 0){ left = true; right = true; lspeed = toInteger(in2); rspeed = toInteger(in3); } if(strcmp(in, "STP") == 0){ left = false; right = false; } }

void act(int l, int r){ //left motor if(left){ analogWrite(lmotor, l); }else{ analogWrite(lmotor, LOW); } //right motor if(right){ analogWrite(rmotor, r); }else{ analogWrite(rmotor, LOW); } }

int toInteger(char input[]){ int output = 0; output += input[2] - '0'; if(input[1] - '0' > 0) output += 10*(input[1] - '0'); else ; if(input[0] - '0' > 0) output += 100*(input[0] - '0'); else ; if (output > 0) return output; else return 0; } void feed(){ if(rfIn.available()){ c = rfIn.read(); if(c == '$') { //Serial.println("data available"); i = 0; c = rfIn.read(); while(c != '\n' && c!= '\r' && c != '*' && i < 19) { buffer[i] = c; i++; c = rfIn.read(); } buffer[i] = '\0'; } } }

Step 11: Building the Boat (Usage)

  • The Arduino setup created in the “receiver” section may be installed in the boat, constructed as described in a separate section.
  • The Arduinos may be powered using any standard powerbank attached via USB printer cable.

Step 12: Boat Chassis (Materials)

You will need:

  • Styrofoam Board
  • Plastic Container
  • Popsicle Sticks
  • Cutter
  • Matches
  • Candle
  • Measuring device (preferably a pencil)
  • Pencil
  • Glue Gun
  • Toothpicks
  • Steel wire
  • Wire cutters

Step 13: Building the Boat Chassis (Central Component)

  1. In this case, the central component should be able to fit the components of the reception circuit and the motor circuit exclusive of the motors themselves. Optimally, the container for the main boat should be as light as possible. In this case, a disposable plastic food container was used, but any plastic container should do.
  2. After ensuring that the components fit inside the container, use the glue gun to secure them, and use the cutter to poke holes in the lid of the container.
  3. Run the wires connecting to the motors themselves through the holes.
  4. Close the lid.

Step 14: Building the Boat Chassis (Pontoons)

  1. Using the ruler, measure the length of the main boat and multiply it by two.
  2. Take the width of the boat and divide it by two.
  3. Use these measurements as a guide for the pontoons and trace them out on styrofoam.
  4. For the purposes of our boat, 4 of these pontoons were built, but more can be added at the discretion of the user.
  5. In order to easily cut these pontoons, light a candle using the matches and run the knife blade over the candle until heated.
  6. Use this blade to cut along the pencil lines in the styrofoam. The heat of the blade should melt the styrofoam and allow one to cut it more easily.
  7. After cutting out the pontoons out of the styrofoam, use the toothpicks to join them together in pairs of two, as pictured here, and then twist the steel wire into loops to hold the engines.

Step 15: Building the Boat Chassis (Connectors)

Now a method must be devised to connect the two pontoons to the main body of the boat.

  1. In this case, popsicle sticks were glued together to form a longer stick, and were then attached to the pontoons and the main boat via glue gun.
  2. Ensure that the main boat is directly in between the two connectors as seen in the picture below, and then use the glue gun to join the container to the connectors and the connectors to the pontoons.
  3. Finally, shove the engines into the steel wire holders and connect their wires to those in the main boat.

Comments

author
Swansong made it! (author)2017-05-15

That looks fun, my nephew loves these :)

About This Instructable

946views

24favorites

License:

More by ReichT:DIY Arduino Catamaran
Add instructable to: