(I) About us:

We are the team SMILE of the vg100 course, from Shanghai Jiao Tong University Joint Institute.

Shanghai Jiao Tong University located in Minhang, Shanghai, China. Studying in JI, we need to develop the abilities of designing, manufacturing and communicating in an engineering way. So we have VG100 course to obtain basic knowledge about engineering and technical communication.

There are five members in our team. The team leader is Liu Yang. He and Wang Xin are responsible for programming and debugging. Chen Yuxin is responsible for designing the bug and the tower and assembling the bug. Wang Bowen is responsible for constructing the tower. Qi Xinyi is responsible for the manual.

(II)Description of the game:

This time we made a Tower Defense game as the first project of the VG100 course.Thegameconsists of a laser tower and a bug, and our main task is to make the laser onthetower catch the bug, which is running along the given path, and "kill" it.[it means tomakethe bug stop when the laser irradiates it.]

The game has two parts. In the first part, the bug should begin to run in a 0.5m protection area, in which the bug cannot be killed. In the second part, the bug should go straight along the path, and stop at the white line, which is 1m from the tower, for 2~4 seconds. When the bug stops on the line, it cannot be killed.


(1)The size of the vertical board in front of the car: MUST be 15cm*10cm

(2)The position of the photo sensor: In the central axis of the board, 5cm high from the ground and in front of the vertical board.

(3)The speed of the bug: in the range of 0.2~0.3m/s.

(4)The height of the tower: not be less than 60 cm

(5) The building materials of the tower: regular printed paper (A4, 80g) and white wood glue.

*Other materials are not allowed to be used as load bearing structure.

(6) Maximum sheets of stacking paper:3

(7)Once the bug got into the race area, the game begins. As long as the game has begun, no one is allowed to touch the car/tower for any reason.

(IV) Our behavior in the game

(1) Bug test behavior

The bug test date is 22/10/2016. In the first round, our bug didn’t go straight and didn’t stop when the laser was shooting at it. Then we found that the problem was due to the loosen screw. In the second round of the test, we succeeded in completing the test.

(2)Game day behavior

The game day is 25/10/2016. In the first round, our team shot zero bug. In the second round, we shot two bugs, but because the light spot was a little bit larger than the specified size, one bug was considered invalid. So finally, our score was one bug that stopped at a distance of 0.4 meters.

Here is the video recording our behavior on the Game Day:


Step 1: Material List

Notice that the exact price may vary with time and country, and ways to buy components is various. So choose the best way to get the components by yourself !

Step 2: Concept Diagram

(I) Concept Diagram ofthebug:

The main controlling system of our bug is Arduino Uno. It is an electronic controller, which can be programmed on the computer and the code can be sent to the board through USB. When receiving digital signals, it processes the original data and send out new signals. We planned to use two motor driving boards to control two DC motors, placed on both sides of the bug. The motor driving board can control the motor by receiving instructions from Arduino. In this way, we can realize the requirement in the rules.

The bug consists of 4 major functions. We use following methods to achieve them.

1. First, bug should when first encountering the first white line for 2 seconds:

1.1 Define a variable “times” as the times for which the bug has entered transverse white lines.

1.2 When the outer led infrared sensors detect the transverse white line, it will report a digit 0 to the Arduino.

1.3 If the Input of outer sensors is 0 and the variable “times” is 0, write 0 to the analogs of the speed of both motors

1.4Delay for 2000ms. Give the variable “times” a new value 1. And it will start again.

2. Second, tocorrect the direction automaticallyhen the bug turns out of the direction:

2.1When the bug turns out of the direction, either the left or the right sensor will detect the black side line and input a digit as 1 to the Arduino.

2.2When Arduino receives the digit, write new numbers to the left and right motors which makes one motor move faster and the other one slower.

3. Third, to stop the bug when shot by the laser in the allowed place:

3.1When the light sensor receives the light from the tower, the variable “illu” reports a value bigger than a constant which is the biggest value under the regular circumstances. If it is shot, the variable “light1”equals to light1+1. If it is not shot,

The variable “light1”will remain the same. Then delay the program for 60 ms.

3.2Circle the program above for 6 times

3.3When the light1 is 6 (which means its value add 1 for 6 times), then the speed of the bug will be written as 0.

Thus the bug stops.

4. Finally, to stop the bug when enter the paper tower.

4.1 When the bug encounters the white line for the second time with the variable“times”equals 1 and the outer sensors input “0”, the analog of both motors will be written as 0.

Thus the bug stops.

(II) Concept Diagram ofthe Tower:

The whole design of the paper tower is based on the frame structure which balances well between the bearing capacity and the weight. The main pillars use the structure of two-layer square tubes to make the paper tower stable. In each point of trisection of the main pillars, we use beams to connect main pillars. The structure of beams prevents the paper tower from transverse extrusion. We also use cross beam structure to hold out against oblique extrusion.

The top of the paper tower uses the structure of corrugated paper to minimize the weight of itself on the premise that it can bear the weight of the objects. The structures above enable the paper tower to keep stable when pan-tilt on it is rotating.

To detect and attack bugs, we use programming based on Arduino Board.

The programming of tower is mainly divided into two parts :

1.Measure the distance between the bug and tower. (Detect bugs)

2.Control two servos to aim the bug.(Attack bugs)

In practical process, distancesof each bug are measured by ultrasonic sensors repeatedly before being sent to the Arduino. Then the Arduino will judge which bug is the priority target and calculate the shooting angle before adjusting the laser by servos.

To cover all bugs on rails, the laser should be adjusted in two dimensions. So we choose

• a 360°servo to ensure the laser can face all four rails

• a 180°servo to aim the laser at the bug

Pay attention that controlling these two types of servos is different in programming.

1. As for 360°servo, only speed and direction of rotation can be controlled. So it is essential to measure how much time is required to rotate from one rail to another one.

2. As for 180°servo, rotation angle can be directly input. So using 180°servo is more accurate to aim the bug on vertical dimension.

Through ways above, we can detect bugs, rotate laser and aim at bugs like a real tower with weapons!

Note: The basic programming knowledge is on the official website of Arduino (https://www.arduino.cc/).

If you still have problems with programming, we welcome your questions by email.

Step 3: Circuit Diagram

(I) Circuit diagram of the bug

First, arrange the power supply system. In this step, we choose a 9V battery to supply power for the Arduino and an 11.1V Model aircraft battery to supply power for 2 motors. The Arduino has the function that it can change the 9V voltage into the suitable voltage. The model aircraft battery supplies strong power for the motors, so that the car can run at the required speed.

Second, connect the GC motors to two motor driving boards. The motor driving boards are connected to the Arduino. Then the Arduino can direct the car to run, stop and change its speed.

Then, connect the Light sensor’s outputto one Arduino pin with DuPont wires.The light sensor will capture the light and change it into digital signals and send it to Arduino. Connect the light sensor to the power pins on Arduinowith DuPont wire, so that the Arduino can supply power for it.

Finally, connect thefour Infrared sensors’ outputs to the pinson Arduino with DuPont wires. When the infrared sensor approaches the black area, it sends different signals to Arduino.In this way, it can change the bug’s direction to keeps it running on the line. Similarly, connect the light sensor to the power pins on Arduinowith DuPont wires to gain power supply.

(II) Circuit diagram of the tower

The circuit of the tower is divided into two parts.

The first part is at the bottom of the tower.We place four Ultrasonic sensors on the four side of the tower, and all of them are connected to the Arduinothrough the four pillars of the tower.Arduino supplies power to them. They sense the distance between bugs and the tower and change it into digital signals.

The second part is at the top of the tower, consists of anArduinoUno, 9 V battery, a pan-tilt, two servos and a laser. The 9V battery is used to supply power to the Arduino and the laser. The servos and the pan-tilt are assembled together. The laser is fixed on the pan-tilt. The servos are connected to the Arduino. The Arduino supplies power to them, and controls the speed and direction of them. When the Arduino receives digits from the ultrasonic sensors, it will instruct the servos. In this way, the pan-tilt turns to different side, and the laser can irradiates the bug correctly.

Step 4: Component Fabrication

a) Preparing the glass

1. Cut the 5mm-thick synthetic glass into 20cm*15cm rectangle as the main structure board.

2. Cut the 3mm-thick synthetic glass into two 4cm*2.5cm rectangle as the boards that hold tires.

3. Cut the 3mm-thick synthetic glass into 15cm*10cm rectangle as the vertical board.

4. Dig holes that are labeled in the picture above.

b) Building the car frame

Stick the head board perpendicular to the base

c) Building the driving wheel components

1. Prepare a reinforcing part, a motor, a motor stand a tire, a coupler and nails for the wheel on each side

2. Pick out the coupler, the tire and the motor.

3. Insert the coupler into the tire. And then insert the motor into the coupler. Remember to fix them with nails.

4. Place the motor on the motor stand. Fix the stand on the supporting structure with nails.

Step 5: Assembly of the Bug


Stick the battery, Arduino Uno, motor driving board and bread board to the car frame


Assemble the axle, couplers for the rear tires and infrared sensor

Assemble the couplers


Assemble the tires


Assemble the rear tires


Stick the driving wheel components to the car frame


Use silver paper to build a side shield


Use DuPont wires to connect all the electrical components together (battery, Arduino Uno, motor driving board, bread board, infrared sensors and light sensor)

Step 6: Assembly of the Tower

a) Assembling main pillar


Cut the A4 paper into a 12cm wide paper slip


Make a fold line every 1.5 cm


Use the white glues to make a two-layer square tube


Make eight tubes in total by using the steps above

b) Assembling beams that prevent the paper tower from transverse extrusion


Cut the A4 paper into a 4 cm wide paper slip


Make a fold line every 1 cm


Cut the slip of paper in half


Fold along the previous made line for two times

Make sixteen beams in total by using the steps above

(c) Assembling beams that prevent the paper tower from oblique extrusion


Cut the A4 paper into a 4 cm wide, 23 cm long paper slip


Make a fold line every 1 cm


Fold along the previous made line for two times


Make eight beams in total by using the steps above

(d) Assembling the corrugated paper


Make a 17cm wide, 17 cm long paper slip


Make two paper slips in total by using the step above


Make a 17cm wide paper slip


Make a fold line every 1 cm


Stick the three pieces of paper together

(e) Assembling the Tower:


Stick two main pillars together


Connect main pillars by using the beams that prevent the paper tower from transverse extrusion


Connect the main pillars by using the beams that prevent the paper tower from oblique extrusion


Add the corrugated paper to the tower

Step (e).7:

Use DuPont wire to connect all the electrical components together (ArduinoUno, battery box, servo, ultrasonic sensors)

Step 7: Final System View

Step 8: Troubleshooting


The first barrier we met was that our bug could not run in a straight line, regardless of our program which could adjust the velocity of each wheel when the bug deviated. After changing the difference of the velocities of two wheels for several times, we finally found the reason. That was the torques of two wheels differed greatly, which meant one wheel might fail to overcome the friction to rotate when the bug ran. We then bought another two motors with same torques to successfully solve this problem.


After we completed our bug, a strange phenomenon happened. Four Arduino boards were burnt out in 14 hours. We checked every circuit node but found no shortcut. Finally, the 11.1v battery on car whose wires were carelessly exposed in air caught our attention. We used rubber tape to isolate the wires and then such phenomenon never happened again.


When we tested the distance-measuring function of tower, we surprisingly discovered that two of our ultrasonic sensors always output no signal. We first assumed that this phenomenon resulted from the changing current which generated a magnetic field. This field might affect the current controlling the sensors. So we tried to make every wire straight and parallel with each other which might reduce the effect of changing current. But it did not work. Finally, to solve this problem, we triggered the sensors by giving it a high level signal for a longer time which guaranteed the stability of the triggering current of the sensors.

Step 9: Reference

{Some online resources we used in Figure5,10 and 11}

[1]Picture of the connectionwires


[2]Picture of the motor driving board


[3] Picture of the Arduino


[4] Picture of the pan-tilt


[5] Picture of the 9V battery


[6] Picture of the battery box


[7] Picture of the screws and nuts


[8] Picture of the laser


[9] Picture of the Model aircraft battery


[10] Picture of the Ultrasonic sensor


[11] Picture of the Infrared sensor


{Some reference resources}



[2] The official website of University of Michigan - Shanghai Jiao Tong University Joint Institute


<p>Good luck in the competition :)</p>

About This Instructable




More by qixinyi-SJTU:Warzone Tower Defense 
Add instructable to: