Introduction: Swimming Robot With a Arduino Uno

Hey everyone, this is my first Instructable, so please go easy on me.

So have you ever wanted to build a small boat like robot that swims towards light, that's what this Instructable is all about. This project is for anyone from Noob to Pro.

Things you need to know:

How to upload a sketch to an Arduino

How to use a Hot glue gun

Common Arduino terminology

If you know all these things then let's get started.

Step 1: Parts List

Things you'll need:

Arduino Uno or other Arduino compatible board

Power supply for the Arduino

Computer to program the Arduino with

USB cord for the Arduino

Breadboard

2 10k ohm Resisters

2 5mm photo resisters

Small servo with 180 degrees of rotation

Servo horn

Jumper wires

Small amount of duct tape.

Plastic clear food tub that the Arduino and Breadbord fit in( i used a longer flat one)

Hot glue gun and Glue for it.

Utility knife

Step 2: Electronic Diagram

Most breadboards have a grid of pins (pic 2), mine has 2 rails on each long side,with 30 rows and 10 columns in between. they are marked 1-30 down and a-j across. we'll be using this system for the placement of everything on the breadboard(ex. a1 = A across and 1 down).

Let's start with the sensor array

1. Sensors

Connect the two leads of a Photo resistor to pins J1 and J3.

Connect the the two leads of the other Photo resistor to pins J28 and J30.

2. Resistors

Connect the leads of one of the 10k ohm resistor to H1 and H5.

Connect the leads of the other 10k ohm resistor to H26 and H30.

3. Sensor + connection

Connect a Wire from the 5V on the Arduino, to the Positive power rail farthest from the sensors

Connect a Wire from the powered Positive rail to F3.

Connect another Wire from the powered Positive rail to F28.

4. Sensor - connection

Connect a Wire from the Ground pin on the Arduino, to the Negative rail farthest from the sensors.

Connect a Wire from the grounded Negative rail to F5.

Connect another Wire from the grounded Negative rail to F26.

5. Arduino connection

Connect a Wire from Analog 1 on the Arduino, to F1.

Connect a Wire from Analog 0 on the Arduino, to F30.

6. Check

Now check to make sure it looks like the above picture(pic 3), Picture 1 is a diagram of the sensors, ignore the servo for now. if everything is good, move on to the next step.

Step 3: Program

Time to program the Arduino.

Connect the Arduino to the computer with the USB cord, start the Arduino IDE and delete everything in the sketch, paste the code from the Arduino Boat file into the IDE. Now upload it to the Arduino.

If your wondering how this sketch works, read on, if not then continue to the next step.

This is how it works. It runs a code once that reads the sensors value, gets the difference, and saves it. It also reads and saves which sensor value is higher.

Now that it has the difference and which one is higher, it repeats code that reads the values and adds the difference to the one that was lowest at the start (this was needed because my Photo resisters and 10k Resisters varied in resistance). It then changes the farthest right point and farthest left point of the servo according to that values, making the flipper change which direction it is paddling, steering the boat.

Step 4: Building the Boat

Now lets start building the Boat.

1. Flipper

We'll start with the Flipper. get a piece of Duct tape that is about 2.5" long. Put the ends
together with both the sticky ends facing each other. You should now have a loop like shape(pic 1). Get the Servo horn from the Servo and stick the arm in at the top of the Duct tape loop(pic 2). Now close the loop from the bottom moving up(pic 3), making a Flipper. Add more duct tape to the front of the flipper making the front less flexible then the back (pic 4).

2. Servo calibration

Use the Servo horn to turn the Servo connection till the Servo is in the middle of its rotation range. Now, without rotating the Servo connection, put the Servo horn on facing straight back and secure it. This easier to do with a clear Servo, as you can look at the gear stop in the Servo to tell the position(pic 5).

3. Tub

Get the Arduino, Breadboard, Power supply, and Plastic food Tub.
Put everything in the tub and slowly put the tub in water, WARNING when you first do this, hold onto the tub and make sure it won't tip. Record where the water came up to on the Tub.

4. Connect the servo

Get the servo with the horn, hot glue it to the back of the Boat where it is able to rotate 180deg and where the Flipper will be partly in the water. On mine, i 3D Printed a mount so i can remove the Servo, without out having to dissemble the Boat (pic 6).

5. Lid

Now get the Lid that goes to the Tub, and cut a small hole that the Servo wires can fit trough(pic 7).

We're done with the Boat, let's put it all together.

Step 5: Putting It All Together

Now you should have a Breadboard with Sensor array on it, a programmed Arduino, and a Boat with the Servo Hot glued on and a Hole in the Lid.

Put the Arduino and Breadboard into the Tub, putting the Photo resisters in the front(pic 1).

Servos normally have three wires, there is a white or orange wire which is the Signal pin, a red wire which is the Positive pin, and a black or brown wire which is the Negative pin. these wires are hooked up to a header, allowing you to connect it easily.

Run the servo cord trough the lid and connect a Jumper wire from Digital pin 3 on the Arduino, into the Signal pin on the Servo(green wire on pic 2). Now run a Jumper from the Positive rail on the Breadboard, to the Positive pin on the Servo(red wire on pic 2). Last connect a Jumper from the Negative rail to the Negative pin on the Servo(black wire on pic 2).

Power up the Arduino and put the Lid on the Tub(pic 3). The Servo should start sweeping from left to right with the Flipper.

Now just put it in water and watch as it move slowly across the water, if you put a light to one side it will turn towards the light.

If everything is working, congrats you just made a cool Arduino Boat. if not, look trough again to make sure everything is hooked up right, or leave a comment and I will try to help you.