I based this off of this really nice instructables.com post for building a water bottle boat, with some additions for obstacle avoidance and light-guided control. I used Arduino as a microcontroller, an ultrasonic sensor in the front, a few simple switches on the side of the boat, and a few light sensors on either side. See here for a few more photos or here for a pdf step by step.
This simple little floating boat bounces off walls, can be steered with a flashlight, and won't hit something head-on.
Step 1: MATERIALS
hot glue + glue gun (silicon optional)
two small DC motors
two water bottles
two small propellors
arduino + USB cable + computer
a plastic box
a 9V battery + a connector
a power diode (like 1n4004)
a soldering iron + solder
a MOSFET transistor or TIP 120
2 few switches + 2 photocells
Step 2: Put the motor in the cap
1. Take off the top of both water bottles
2. Poke a hole in each cap
3. Apply hot glue to the inside of the cap, but not on the hole. Slip the motor shaft through the hole. When dry, the shaft should spin freely.
Do this with both bottle caps and motors.
Step 3: Tape the water bottles together
Use two or three strips of tape to tape the water bottles together, sort of like a raft.
Step 4: Solder leads to the dc motors if there are none
The motors are now attached to the bottle caps.
Solder on long (about 10") leads to the motors, if there aren't any.
Step 5: Cut a slit in the water bottle
Cut a small slit in each water bottle.
This is the hole through which the wires from the motors will poke through.
Step 6: Put on the cap and feed through the wires
Put the cap on the bottle and feed the wires into the bottle opening, then out the slit that you just made. If you have trouble screwing on the cap, use some hot glue to secure it.
Step 7: Make the electronics house
Glue a plastic box to the top of your two bottles. You can bring the wires from the motors around the back, or poke a small hole in the side of the box to feed them into.
Now, put a bit of hot glue on the holes you made in the bottles to make sure the bottles are watertight.
Step 8: Build the circuit
This circuit uses a TIP 120 (or similar Darlington or MOSFET) transistor, which is an electronic switch.
It uses it to power a high current load because Arduino does not output enough amperage to turn the motors.
Follow this schematic for the first motor. Then, build the SAME circuit for the second motor, on the breadboard.
(You do not need a 9V battery second power source)
Step 9: Add some sensors
Get creative! you don't need all these sensors. but add them as you like.
Ping Ultrasonic Rangefinder by Parallax works nicely on the front of the boat so it knows if something is in its path.
Photocells can act like antennas if you want a boat that steers towards light (for example).
I'm a fan of two simple switches, mounted on the sides of the boat, acting as obstacle detectors.
You can also modify the code and use some Infrared proximity sensors to detect short range obstacles
Step 10: Circuits for the various sensorsirc
See images for a circuit for a simple button with a 1K resistor. Do this for two buttons, so you can mount them on both sides of the boat so that if it hits something on either side it can adjust its steering accordingly. More information for this circuit and sample code can be found at www.arduino.cc/en/Tutorial/button
See image for a circuit with a photocell with a 1K resistor: Do this twice, also, so that you can include a photocell on both sides of the boat. For more information and sample code, see the analog input example at www.arduino.cc/en/Tutorial/AnalogInput .
Step 11: Write some code or download it
You can download some super simple premade code I wrote to give the boat basic functionality. There is code for a light-following boat and a boat with an ultrasonic rangefinder, with two buttons as obstacle sensors.
Here is my code for a boat with an ultrasonic sensor, two photocells, and two switches for obstacle avoidance
The way I have it operating is that if the boat approaches an obstacle ahead, it turns to avoid it. If the boat hits something from the side, it turns away from the barrier.
But here you can find various codes for the boat if you dont want to use all of the sensors, but just some of them https://github.com/gabriella/boat-
Or write your own.
Step 12: Box everything
Put your circuit, arduino, and battery in the box.
Step 13: Upload the sketch
Select the correct board and correct port.
Compile and upload the sketch.
Step 14: Waterproof and get ready for testing
Put the top of the box on. Seal up all the holes or potential leak spotswith hot glue (or silicon). Glue any stray wires with hotglue (like the photocells or the buttons so they dont short in the water.
Glue on the propellers to the motor shaft sticking out the cap.
test it out on the water!