Vehicular Combat Game: With Sound Effects and Flashing Lights!

by JD_K in Circuits > Arduino

1829 Views, 21 Favorites, 0 Comments

Vehicular Combat Game: With Sound Effects and Flashing Lights!

CoverShootingRedTopTitlePNG.png

How to Play:

The controls to drive the car are simple: forward, backward, turn right, turn left. The car will move in a straight line until you press stop. The turning is done in short segments for ease of control. There is one button to shoot, which lasts 2 seconds, the gun lights up and there are shooting sound effects. You have to make your shot count, because then there are 3 seconds when you cannot shoot. If you are hit by your opponent, your car shuts down and the headlights flash for 5 seconds. Your car will start moving again, but if you get hit 3 times before your opponent(s) do, you are out of the game. But if you can get back to base before that, you can repair all the damage! Good Luck and Happy Hunting.

Supplies

Arduino RC Vehicular Combat Game: Playing Around | 1 of 4 videos
Arduino RC Vehicular Combat Game: Weapons Test | 4 of 4 videos
1PolystyreneSheet.jpg
2 IMG_1789 copy.jpg
3 IMG_1790 copy.jpg

The first thing to do is to gather all the electrical components to make sure you have everything. If you do not want to do any soldering, ultimately you could create your car with just solderless breadboard connections.


Electrical components that go into the finished car:

  • Arduino Uno
  • MP3 player module
  • MicroSD card (for saving the sound effects)
  • Speaker (8 Ohm)
  • Bluetooth transceiver (HC-05 or HC-06)
  • Male and Female header pins
  • 90-degree male header pins
  • LD293 motor driver
  • 16-pin IC socket (for the motor driver)
  • Hobby gear motor with wheel (x2, I used 5-volt motors)
  • 220 Ohm resistor x3 (ONE for each red, both blue, and IR LEDs)
  • 1 kOhm resistor x2 (one for Bluetooth Rx pin (optional) & pin 10 of MP3 player)
  • 2 kOhm resistor x1 (for Bluetooth Rx pin(optional))
  • 10 kOhm resistor x1 (for Hall effect sensor)
  • 100 kOhm resistor x4 (for IR photodiodes)
  • 100 nF ceramic capacitor x2 (optional? for each LD293 & positive voltage of the IR photodiodes)
  • Hall Effect sensor x1 (digital type like Y3144, not linear)
  • Large flat magnet (to lie on the floor, not attached to the car)
  • IR photodiodes x4 (used as sensors to detect being hit)
  • Infrared (IR) LED x1 (used as the gun)
  • Red LED x1 (for the gun)
  • Blue LED x2 (headlights)
  • DPDT sliding switch (on/off for the batteries)
  • Tactile switch (reset button)
  • Wire (male & female jumper wires, other wire for connections)
  • Heat shrink wrap (various sizes)
  • 4-battery AA battery holder
  • AA batteries (x4, alkaline)
  • 9V battery clip
  • 9V battery


For the body of the car:

  • Rotating Caster x1 (4.5cm, for the front wheel) 
  • Polystyrene sheets (3.2mm thickness (picture 1), but I also used 0.5mm)
  • Polystyrene, 4.8 mm L-shape angle strip (to reinforce joints) (picture 2)
  • Polystyrene, 4.8mm X 7.9mm rectangular tube (for blocks to hold roof) (picture 2)
  • Polystyrene, 8.7mm circular tube (for gun barrel, headlight, etc.) (picture 2)
  • Testers model glue (picture 3)
  • Modeling putty (Tamiya Putty 87095, white) (picture 3)
  • Super glue (“CA glue”, for gluing header pins together like the Bluetooth connector)
  • Screws x5 (M2 10mm, three to hold the perf board, two to hold the roof)
  • Screws x2 (M3 30mm, to mount the gear motors)
  • Screws x6 (M3 10mm, to hold the batteries and caster)


Tools:

  • Solderless breadboard (when prototyping the circuit)
  • Digital multimeter (VERY useful for prototyping and troubleshooting the circuit)
  • Arduino IDE software (free download)
  • Sharp hobby knife
  • Sand paper (50grit, 150 grit)
  • File (a flat and a round one)
  • Precision screw drivers (for the screws, and to manipulate the leads when soldering)
  • Cordless drill with various-sized drill bits
  • Soldering iron, solder
  • Flush cutters
  • Wire striper
  • Locking pliers (optional, but I used it when making the front panel)
  • Masking tape
  • Ruler
  • Set square
  • Digital calipers
  • Compass from a geometry set (to draw circle)
  • Hot glue gun
  • Black spray paint

The List of Connections

4 IR Gun Car_MP3_Bluetooth_reset_FRITZINGpng copy.png
LooseComponents.jpg
AllConnected.jpg

This step contains all the connections for the various electrical components. Use this list and the Fritzing image (picture 4) to get a sense of how things are connected together. In the following steps I will go through the programming (“sketch”) and then components individually. For some people, this step and the Arduino sketch is all they need. 

 

Arduino UNO or Nano:

  • Reset Pushbutton (with the other side of the button connected to ground)
  • 5V Many components (IR photodiodes, pin 16 of LD293, pin 9 of MP3 player, Vcc of the Bluetooth module, anode of Hall effect sensor)
  • Vin Power switch, which will connect to the 9volt battery
  • A0 front IR photodiode
  • A1 Right IR photodiode
  • A2 Left IR photodiode
  • A3 Back IR photodiode
  • A4 Tx of the MP3 player (pin 11)
  • A5 1k Ohm resistor to Rx of MP3 player (pin 10)
  • D0 Tx of HC-06
  • D1 to voltage divider for Rx of HC-06 (to the 1k, which connects to the Rx AND 2k; 2k to GND)
  • D2 Hall effect (must be on D2 as this is an interrupt pin)
  • D3 (not used)
  • D4 IN1 (L293D “M1 direction 0/1” or pin 2)
  • D5 ENA (L293D M1 PWM or pin 1)
  • D6 ENB (L293D M2 PWM or pin 9)
  • D7 IN2 (L293D “M1 direction 1/0” or pin 7)
  • D8 IN4 (L293D “M2 direction 0/1” or pin 15)
  • D9 IN3 (L293D “M2 direction 1/0” or pin 10)
  • D10 “Busy” pin of MP3 player
  • D11 Red LED in Gun (PWM)
  • D12 IR LED
  • D13 single 220 Ohm resistor to two LED headlights

The cathode of the four infrared (IR) photodiodes are also connected to ground:


Hall effect sensor with the label facing you:

  • Leftmost pin     to Arduino 5 volts
  • Middle pin        to Arduino ground
  • Rightmost pin  to 1) a 10k Ohm resistor which is also connected to 5 Volts, and 2) to Arduino D2


Two Headlight LEDs

  • Both LEDs in the gun have a common GND to Arduino GND
  • IR LED anode    Arduino D12 via 220 Ohm resistor
  • Red LED anode Arduino D11 via 220 Ohm resistor


HC-05 Bluetooth Module

  • Vcc to Arduino 5V
  • GND to ground
  • Tx to Arduino D0
  • Rx to middle of voltage divider (2k to GND; and 1k to Arduino pin D1)

**The Arduino Tx connection to the Bluetooth Rx is optional. As the program as is does not need to communicate back to the remote control.


MP3 player (with card slot facing away, pin 8 is bottom left)

  • Pin 8 to Arduino D10
  • Pin 9 (Vcc) to Arduino 5V
  • Pin 14 speaker+ to one speaker wire
  • Pin 15 to ground
  • Pin 16 speaker- to other speaker wire


L293 Motor Driver (end with the semi-circular divot facing away, pin 1 is the top left, pin 9 is bottom right):

Left side For Left Motor: pins 1 to 8:

  • Enable1 pin of L293D to D5 of Arduino which is a PWM pin,
  • M1 direction to D4,
  • OUT1 to left motor,
  • 0V to ground
  • 0V to ground
  • Out2 to left motor,
  • IN2 of L293D to D7,
  • +Vmotor pin of L293D to the V+ for the motor

Right side For Right Motor: pins 9 to 16:

  • Enable2 pin of L293D to D6 of Arduino which is a PWM pin,
  • M2 direction to D9,
  • OUT1 to right motor
  • 0V to ground
  • 0V to ground
  • Out2 to right motor,
  • IN2 of L293D to D8,
  • +V to the Arduino 5V


Reset Button (tactile push button):

  • One electrode to Arduino reset pin
  • Opposite electrode to Arduino ground

The Arduino Sketch

Download the Arduino sketch below and upload it to your Arduino (UNO or Nano). You will need the Arduino IDE (internal development environment). If you are not already familiar with this, then this project may be too challenging for your first project. 


I have put many explanatory comments in the sketch so I will not go through all the details here. There is one library (a library is a published piece of code you can download from the internet and use) you will need, which is the DFPlayer_Mini_Mp3.h It can be downloaded HERE. This library, as the name implies, is used to operate the mp3 player. The other library that is needed is the SofwareSerial.h which comes with the Arduino software so you will not need to download it. This library allows the Arduino to communicate with the mp3 player. In this sketch, I used pins A4 and A5. These are usually used for I2C communication, but I am not using that in this project, I was just running out of pins.


The sketch begins as most programs do, defining variables and which pins are used to for connecting the different components. There are two variables, referred to as “gunTime” and “reloadTime” in the code, can be changed in the programming to make it easier or harder to shoot the other car. If you did not want a reload time, the two LEDs could be connected to the same digital pin and just be turned on and off.


Then there are several functions I created to drive the car, such as forward(), back(), etc. There are functions to activate the LED, such as LEDtoggle() to turn the headlights on/off, and shoot() which activates the gun and sets the timing for the gun to deactivate.


The function void resetHitCounter() is the interrupt function associated with the Hall effect sensor. If the car gets hit, this interrupt is “attached” meaning it will now work. Then when the sensor is dragged over a magnet, this function is called which returns the hit counter back to zero, and “detaches” the interrupt function. So, it will not work until it is attached again. This is the only time I have seen anyone detach an interrupt function, but it is important here and prevents the interrupt from interfering with normal function.


There is a function called long readVcc(). I learned this from Andreas Spiess’ YouTube post. It is a way of calculating the exact voltage being used by the Arduino, so that you can get more accurate analog readings. The “long” is there because it lets the Arduino know that this function is generating a number in the form of a long variable. This value is then used in the subsequent function calibrateIR() to get the accurate ambient IR readings. As I explain later, I included this in an attempt to troubleshoot the photodiode circuit.


The setup() section of the sketch is fairly short. Communication is set up as well as declaring the digital pins as inputs or outputs. The ambient infrared reading is taken. Then most of the loop() is 1) reading the serial buffer where the commands from the Bluetooth module are temporarily stored and based on the command, calling the appropriate function to drive or activate LEDs, and 2) checking the timing of things to see if the car should stop shooting, or if it is time to check the IR photodiodes. This last check is done about every 100 milliseconds, and if the difference between the ambient IR and current IR readings is large enough, then the stop() function is called to stop the car, and the headlights flash. Since the serial buffer is not read during the five second the headlights are flashing, the car cannot move or shoot. If it has been more than 2 hits, the Arduino is stuck in a look which continuously flashes the headlights until the reset button is pressed.

Bluetooth Transceiver

5 BluetoothConnector1 copy.jpg
6 PrepSocketPullPin copy.jpg
7 PrepSocketCutFemalePin copy.jpg
8 PrepSocketFiling copy.jpg
9 BluetoothConnector3 copy.jpg
10 IMG_1787 copy.jpg

For the Bluetooth, I used an HC-05 Bluetooth module, but you could use any of the common modules. I chose Bluetooth over using a radiofrequency (RF) transmitter to make this project more accessible to more people. Some new users find that Bluetooth is easier to get working than a RF transceiver like the nRF24L01. Moreover, with a RF system you would need to not only to construct the car, but also the remote control. With a Bluetooth control system, you can use any smartphone or tablet, and just download a free app and use that as your remote.


Making the connections (see picture 4): You do not need to connect to the Rx pin of the Bluetooth module as the Arduino isn’t sending any signals for the Bluetooth to receive. (However, I put in that connection out of habit.) The transmit (Tx) and receive (Rx) pins of the Bluetooth are connected to the Arduino D0 and D1 pins. Thus, Tx of the HC-05 is connected to the Arduino Rx, and the Rx of the HC-05 is connected to the Tx of the Arduino. Since the Arduino works on 5 Volts, and the Bluetooth module works on only 3.3 Volts, the Tx signal from the Arduino must go through a voltage divider to bring down the voltage on the Bluetooth Rx pin, otherwise it could be damaged. That being said, the HC-05 Vcc pin is able to tolerate 5 Volts, and the 3.3 Volts of the Rx pin is high enough work with the Tx pin of the Arduino. Because I am using the HC-05 there are two unused pins. If yours only has four pins, they will be the same four that I am using here.


For the car, I created a custom connector to connect the Bluetooth module to the perf board (picture 5). The Bluetooth end is a row of 6 female header pins, although only the middle four are used. Normally, a row of female header pins is sold in a row of 40. To make a custom size, count out the desired number, in this case six, then with needle nose pliers pull out the next pin (picture 6). Clip or cut through the plastic at that spot where the pin was (picture 7), and file the edge flat (picture 8). Since only four pins are being used for this connector, four wires are then soldered on. The other end of the connector has a 2x2 arrangement of male header pins. These four male pins are glued with crazy glue. I covered the ends of the soldered wires with shrink wrap (picture 9).


IMPORTANT NOTE: The D0 and D1 pins are the same Rx and Tx pins that the computer software uses to program the Arduino. If you need to change something in the programming, you must disconnect the Bluetooth module during the upload to the Arduino, otherwise the Bluetooth can interfere with the upload. After the upload is complete, simply plug the Bluetooth module back in and pair it with your device once more.


To use the Bluetooth: download an app with a “remote control” mode to your device. In some apps, you may need to pair the device with your Bluetooth module (see the next paragraph) before you can go to the settings. Whichever the case, open the app and in the settings (picture 10), you will need to change the signal associated with the controls of the remote as the car is expecting certain signals. These signals are basically single letters, in quotes below, sent from the device that the car receives and completes a specific action.


These signals are:

  • Up Arrow = “f” (Drive Forward)
  • Right Arrow = “r” (Turn Right)
  • Left Arrow = “l” (Turn Left)
  • Down Arrow = “b” (Drive Backwards)
  • Any of the four buttons on right = “s” (Stop)
  • Start = “x” (Shoot)
  • Select = “a” (Toggle Headlights On/Off)


You will need to pair the device to the car, each time you power up the car. There might be different ways of doing this depending on your Bluetooth module, the device (phone or tablet) you are using, and the app. However, I will try to explain here how I think you will need to do it if you have never done it before. …To pair the app with the car, turn the car power on. The Bluetooth module should have a (red) blinking light that flashes on/off about once per second. This indicates it is in pairing mode. Turn on the Bluetooth function of your device, and look for the name of the Bluetooth module in the list of detected devices. It may be “HC-05” is you are using one like mine. Select that, and wait a few seconds for the devices to pair. You may need to enter a password, which are usually “0000” or “1234”. When the pairing is complete, you should see the flashing light slow in frequency, like 2 seconds on, 2 seconds off. Now you can open the app if you have not done so already.

Start Testing Everything Out

This is an important step and the trickiest part. My car works, but if you are like me, chances are good yours will not on the first try. This always happens. Keep at it. You can try to ask me questions, or google for information online. Chances are someone else has had the same problem. Make notes to yourself of what does not work, and what you have tried. Your notes can help if you cannot get everything working all in one sitting. If something does not work turn the power off right away, and double check the connections (do you have the right pins? Did you forget anything? Did any of the jumper wires spontaneously disconnect?). Double check the Bluetooth is connected, and the settings in the app are correct. Use the multimeter and see if you are getting power. For information on each component, see their respective sections later in the Instructable.


With the Bluetooth connected and paired you can test out components one at a time. Starting with the Bluetooth itself. Can you connect the app you downloaded to the Bluetooth module? Using the headlight button on the app, can you turn on the D13 LED or not? It should turn on/off even without the “headlights” connected. If that works, you can move on to the next component.


On a Breadboard, try the 4 LEDs (not the photodiodes). Connect them to the Arduino with jumper wires being sure to include the resistors. These should light up with the “Shoot” and “Toggle Headlights On/Off” buttons on your remote control. Or if you would rather, you can use the Serial Monitor of the Arduino IDE and just type in the single letter for each function. This is also a good time to check the current consumption with a multimeter and be sure you are not exceeding the LED’s specifications on the datasheet.


Since the IR light is invisible, the red LED is included for a visual effect to show the gun is shooting. When the gun is activated, both the red and IR LEDs are activated by Arduino digital pins for two seconds, then the IR LED turns off, and the red LED dims. This is to indicate the three-second “reload” time during which the gun cannot be activated. This is dimming is done through the use of pulse wave modulation (PWM) and therefore the red LED is connected to pin D11 which is one of the pins with this function. If you want to see if the IR LED is working, use the camera on your phone. The IR light will show up as a purple-ish colour which your naked eyes do not see. Note, the Amazon link where I bought mine is no longer available, but I did find one that looked similar here.


For the headlights, I chose blue because I like the colour of these LEDs. When you press the toggle button, they should stay on or stay off.

MP3 Player

Arduino RC Vehicular Combat Game: Sound Test | 2 of 4 videos
11 MP3.jpg

Next, connect the MP3 player (picture 11) on your Breadboard. I recommend using the DFRobot MP3 player, or one very similar. I have used a different player in the past, but it needed an external amplifier to get any sound from it. There are several tutorials for using the DFRobot MP3 player, so I won’t go into further details about using it here.


You will need to add some sound effect(s) to the microSD card. All android devices have a microSD slot that you could use. I use my computer, but you might need an adapter to plug into your computer. For the sound effects, you can record them with your device and save them as an MP3 file to the microSD card. You should have some “Voice Recorder” or “Audio Recorder” already on your device. Alternatively, you can search the internet for free mp3 files and saved them to the microSD card. There is a way to program the MP3 player to play specific sounds for specific events (like getting hit, healing the damage, losing the game, turning lights on, etc.) but to keep things simple I have kept it to only shooting sound effects.


Now that you know the MP3 Player works, remove it and the connections from the breadboard but keep the LEDs and the Bluetooth module. This keeps thing simple as you move on to the next component.

The LD293 Motor Driver

12 LD293 copy.png

There are lots of online tutorials for using integrated circuit (IC) so I won’t go into a lot of detail here. You can see the connections in picture 4. I did add a 100nF capacitor which may not be necessary. At this point, the direction of the motors is not important, you just want to make sure they will turn when you use the driving controls on the remote.


A couple of tips about this IC, pin 8 (picture 12) is the voltage that will go to the motors, and pin 16 is the voltage for the digital circuitry inside the IC. Often in tutorials these will both be the same voltage, and no distinction is made, but these are not interconnected. It is better to have separate power sources, so on the breadboard, power pin 16 from the Arduino 5V, and pin 8 from the four AA batteries. Lastly, the voltage delivered from the motor driver, even at full PWM signal, is about 1 volt lower. So, for example, when I used 4 NiMh rechargeable AA batteries, with a combined voltage of 4.8 volts across the batteries when Niamh one motor was running. The voltage on the motor itself (i.e., from the LD293) was 3.9 volts. It worked, but if you want it to go faster, you will want the higher voltage. Five batteries in series would give you the 5 volts to the motors.


Remove the motors, motor driver, AA batteries and their connections.

The Infrared Photodiode Sensors

13 Photodiode1 copy.jpg
14 PhotodiodeStretchShrinkwrap copy.jpg
15 Photodiode2 copy.jpg

These look like black LEDs, and came with the IR LEDs. Here they are the sensors used to detect if the car has been hit. The two connections to each photodiode are long wire and pass through the body of the car and hot glued to their respective locations under of the car.


How it works: Normally, with this setup, when the analog input pins are polled in the programming, each read a maximum value of 1023. When the photodiode is exposed to the infrared light of the IR LED and the pin is polled, the value returned is lower and this is counted as a hit. For five seconds, the car stops, cannot be hit again, and the headlights blink each second for the same number of times as the hit counter. For example, if the car was hit, then minutes later hit again, the headlights double flash once a second for five seconds. If this is the first hit, the interrupt function for the Hall effect sensor (see below) is turned on in the programming. If the internal hit counter has reached 3 (i.e., 3 hits to the car), the game is over and the flashing will continue until the Arduino is reset.


To test this, point the IR LED at one of the photodiodes. If it is working, the headlights should start to flash once a second. After the five seconds, if you do it again, the headlights should double flash every second for five seconds. By the way, without any focusing lens the range of the IR gun is not terribly long. However, it means you have to get up close to the opponent’s car which builds the suspense when playing!


I will say, during the prototyping, it was difficult to get this system working consistently. The car would randomly respond as if it got hit, even when stationary and no other car around. Therefore, this version has a number of changes from the prototype to try to minimize any interference.

  • The motor wires and battery wires are kept separate from the photodiode wires and cross to the underside of the car through separate holes.
  • Similar to the prototype, but I will mention it here because it is important for minimizing interference with motors, the Arduino power source (a 9-volt battery) is separate from the motor power source (four AAA batteries).
  • A 100 nF capacitor was added between the short 5-volt “bus” for the 100kOhm resistors for the photodiodes. The other lead of this capacitor was connected to ground.
  • Although I only partially done on this car, the ground wires from each photodiode are kept separate from ground of other components as much as possible.
  • Lastly, with the trueVcc() function, the actual “5-volt” Vcc is calculated before any analog measurement. (See the Andreas Spiess YouTube link for more information)

This car works better than the prototype but can get hit spontaneously, but this may be more of an issue of the 9-volt battery getting low. This part is still a work in progress to get it consistent.


I used black and white female jumper wires for insertion of the two leads (picture 13). These are held in place with shrink wrap (picture 15), that I had to stretch with needle nose pliers just a little bigger to get it to fit (picture 14). The other ends of the jumper wires were eventually soldered to the perf board.

Anyway, if your photodiodes are working, keep them as it is time to test out the Hall effect sensor.

The Hall Effect Sensor

16 HallEffect2shrink copy.jpg

As part of the shooting game, the cars can take up to 3 hits. At that point, game over. However, using this Hall effect sensor, which is a magnetic sensor, the cars have the ability to “heal” the damage.


When selecting a Hall effect sensor (picture 16), be sure to get a digital one (e.g., Y3144), not a linear one. Also keep in mind, that Hall effect sensors are polarized. One side will respond to the North side of a magnet, the other side will respond to the South side. To connect the sensor, it is placed at the end of three long female jumper wires (one for each lead of the sensor). It is sheathed in shrink wrap to hold it in on the jumper wires and to protect the sensor from friction as it will be mounted so that it will drag on the floor under the car (picture). If the car is hit, the program activates the healing ability (the interrupt function - see above), and if the car drags this sensor over a magnet, the hit count is returned to zero and the healing ability is switched off.


To test this sensor, point the IR LED at one of the photodiodes, and press the shoot button on the controller. Now pass a magnet against the Hall effect sensor. If it worked, then when you shoot a photodiode again, you should only see the single flashes, not a double flash, as the magnet caused interrupt function, which returned the hit counter back to zero before the car was hit again.

Putting All the Electronic Components Together

20 Headlights.jpg
17 PrepSocketPlacingMP3 copy.jpg
18 IRandRED_LEDs copy.jpg
19 IRandRED_wires copy.jpg

If you would rather not solder then just place everything on a breadboard, then now that you know each component works, you could assemble everything together and mount the breadboard, LEDs (on jumper wires), photodiodes (on Jumper wires) and motors on the body of the car.


If you plan to solder everything, then you will need a perfboard and figure out how to arrange everything, keeping in mind you will need to install them on whatever car body you decide to go with. You also have to plan out what will be removeable. If you want to be able to remove the top of the car and have components permanently attached to it, then you must be able to disconnect the wires to that component. It is also useful to have sockets as these let you swap out parts that may stop working, or swap for another project. The LD293 has its own 16-pin DIP socket, the MP3 player uses two rows of 8-pin female headers (picture 17) to create a socket.


The two LEDs for the gun can share a common ground wire (picture 18) attached to both cathodes. However, there should be one wire to each anode (picture 19), so the red LED can operate independently of the IR LED. These will need a male pin at the end to plug into female headers on the perf board. The blue headlights (picture 20) have a ground wire that I attached to the ground connection of the gun but these are just twisted together so that if needed the front panel can be fully removed from the rest of the car.


For the motor connections, if, when you connect everything, your car turns when you want it to go straight, you may have to switch the motor’s connections. For example, if you direct the car to drive straight but it turns quickly and continuously to the left, then you probably need to reverse the two connections of the left motor as the wheel is spinning backwards when it should be going forwards.

The Body: Working With Polystyrene

21 General dimensions copy 2.png
22 AnalogWiresDone copy.jpg
23 Back_Placing copy.jpg
24 CuttingSquare copy.jpg
25 PliersCut1 copy.jpg
26 PliersCut2 copy.jpg
27 PliersCut3 copy.jpg

The construction of body of the car is up to you. If you have a 3D printer, you can make something really cool! Or you could buy a model car from a hobby shop that is big enough to fit all the components. My original prototype was a simple piece of fiberboard, cut in a rectangle, with the Arduino on spacers and the two motors zip-tied to the board. My point is, there are many options and you can hack something up quickly, or spend time to make something really detailed. For this Instructable, the base, sides and top are from 3.2mm polystyrene. These are suitable because they are fairly sturdy. I included the general measurements of the body (picture 21) if you would like to make something similar. And using a perf board for the components with wires running back to the Arduino (picture 22), rather than a stackable shield allowed the car to be lower and less like a brick on wheels (picture 23).


To work with polystyrene, cover it with masking tape to protect them from scratches and to allow labelling which side is top/bottom, draw lines for planning the layout and mark where the holes needed to be drilled.


To make cuts in the sheets: With a pen trace out the cuts on the masking tape. Then with the ruler or square make about 3-5 cuts with a sharp knife (picture 24). Start these cuts with gentle pressure, concentrating on making the lines straight along the edge, then make deeper cuts with a little more pressure. Then push a cut on either edge of the sheet. These should be aligned with your long cut, and perpendicular to the surface of the sheet. All these cuts will make the polystyrene easy to snap along this line. If you are cutting a small piece, like smaller than a centimetre wide, score it with a knife with the 3-5 cuts (picture 25), cover the piece with a few layers of masking tape (picture 26) to prevent marring the surface and use pliers to help break the piece off (picture 27). Whatever the cut, the edge of the plastic forms a bit of a lip, like it was swelling next to the cut, so you may want to sand with extra fine sand paper. Use sandpaper with at least 150 grit or higher to prevent it looking too scuffed. The cut itself will not be 100% clean either, so sand the edge with coarse sand paper, then work up to a fine grit to make it smooth.


To stick pieces together, the testers model glue works by melting the plastic which then dries to form a really strong bond. Where needed, I reinforced some joints with L-shaped pieces of polystyrene. After things were dried, I added some Tamiya paste to fill in the gaps, then sanded the excess paste with fine grit sand paper until it was smooth.

The Body of the Car

28 FrontPanelTracing copy.jpg
29 EdgeOfFrontPanel copy.jpg
30 HeadlightClamping copy.jpg
31 Headlight_Drilling copy.jpg
32 CuttingHeadlightCovers copy.jpg
33 CuttingHoleForGunWires copy.jpg
34 Gun copy.jpg
35 MotorMounts copy.jpg
36 MountingMotors2 copy.jpg
37 MountingMotors1_Gluing copy.jpg
38 Bottom copy.jpg
39 SandingBlock1 copy.jpg
40 SandingBlock2 copy.jpg
41 Sanding copy.jpg
42 SandedEdge copy.jpg
43 Speaker2_Back26mm copy.jpg
44 Speaker3_Compas copy.jpg
45 Speaker4_perforations copy.jpg
46 Speaker6_RoughHoleCut copy.jpg
47 ResetWired copy.jpg

The front panel of the body is made from a trapezoidal piece of 0.5 mm thick polystyrene (picture 28). In the end, I think having the front panel made from the 0.5mm polystyrene was not the best idea. It is easy to work with, and the thin edge of the panel looks better than if it were 3mm thick, but its too flimsy. Anyways, I positioned the panel, being careful to line up the edges on the front of the car and glued short pieces of the L-shaped polystyrene that would hold the panel in place and prevent the front panel from sliding forward. These were glued to the underside of the front panel itself, but not against the side walls of the car so the panel can be removed. Be careful to use a small amount of glue, if you use too much, the glue will melt through to the top surface of the panel. Near the end of construction, I found that the wires inside the car prevented the front panel from resting tightly against the car. So, with small pieces of 3.2 mm glued to L-shaped pieces (picture 29) of the front panel, and new L-shaped pieces glued to the inside of the side walls of the car, I created four tabs so the front panel will slide into place but be held firmly against the body of the car.


Drilling holes into the 0.5mm plastic risks tearing it. So, to mount the LEDs in the front panel, place masking tape over the panel and measure out where the LEDs need to be. Then mark the plastic with a pen. Drill a small hole into a scrap piece of polystyrene, and centre this hole over the pen mark on the hood. Clamp this plastic to your front panel along with a second scrap piece on the back. Small lockable pliers work great (see picture 30). This was done to centre the hole when drilling (picture 31) and to use the scrap pieces to hold the thin polystyrene so it would not tear. To make covers for the headlight, cut and sand two short, angled pieces of the polystyrene tube (picture 32). Place these facedown on smooth hard surface (tile floor in my case, but I hear packing tape would work) and fill just the front of the tubes with hot glue to make the headlight “lenses”. Place your blue LEDs to the front panel with hot glue, pointing forward, and position the covers over the LEDS, gluing them with model glue.


For mounting the gun, decide where it should go on the angled front side of the car. The gun should be mounted at the same height as the IR photodiodes of the other car(s) so you will need to plan a hole in the side wall to accommodate the wires (picture 33). For the barrel, cut a piece of polystyrene tube long enough to hold both the IR and red LEDs. Cut then sand the one end of the barrel so it accommodates the angled front of the car but still points straight (picture 34). These two LEDs should be lined up inside the tube with the IR LED sticking out the front and a red LED right behind it. When it was time to hot glue the two LEDs inside the gun barrel, I put a small white twist tie (it’s what I had close to me; see picture) wrapped around the lens of the IR LED to help center it. Both were placed in the tube and hot glue was injected from the back of the gun. The twist tie was removed when the glue was cool.


The mounts for the two motors are triangles cut from the 3.2mm polystyrene sheet. These where then glued to pieces of L-shaped polystyrene so that they could be glued to the underside of the body (picture 35). When gluing the L-shapes, each motor will need two triangles which are mirror images of each other. With the L-shape glued in place, I held each triangle one by one in place against the motor and inserted a drill bit through the hole in the case of the gear motor to mark where on the triangle to drill a screw hole. Then drilled the hole without the motor. Later I re-made the outer triangle for each motor with the thinner 0.5 mm polystyrene as the M3 screw that holds the motor would interfere with the wheel when it was the 3.2mm thickness (picture 36). Wait until the end of construction before gluing the triangular motor mounts as they will stick out permanently from the body which makes it hard if you are still working on the body (cutting, sanding, drilling, etc.).


The bright yellow colour of the gearbox and wheel rims did not go with the rest of the car. So, I removed the rubber tires, and used masking tape over the motors, wires and two layers on the motor shafts (which was thick enough to prevent paint getting inside) before spray painting with a flat black. The triangles were not painted. When it comes time to attach these motor mounts, secure both triangles with a single 3cm M3 screw through the triangles and gearbox (be sure the wires on the motors will face inwards). Apply some model glue to the top surface of the L-shaped pieces of the motor mounts then glue them in place on the undersurface of the body (picture 37). These will need to be placed such that there is space for the IR photodiodes, battery case, screws for holding the Arduino and perf board, wires to pass through the body, etc. (picture 38).


For the top cover, I used two perf boards to make an “offset” sanding block to reduce the thickness where it sits on the two side walls (pictures 39-42). I just did not like the look of how thick it looked from the side. I glued square pieces of the rectangular tubing to hold it in place, as well as added a screw on each side to make sure the top stayed secure. I mounted the speaker flat. The outer edge of the speakers was 28mm, and there is a raised circular part on the back of 26mm (picture 43) which allows the speakers to easily seat on the surface. The hole was traced out with a compass (picture 44), then several 2mm drill holes were cut just inside the circumference of the circle (picture 45) to perforate the plastic. This perforated circle was then cut out with a knife (picture 46) and smoothed out with a circular file. With longer jumper wires soldered to the speaker, glue it on the top cover with hot glue. I installed a black reset button next to the speaker which will connect Reset pin of the Arduino to ground (picture 47). That way when it is Game Over, it is easy to press this button and the car will work again. 

Adding Other Details

48 Rear copy.jpg

There are some final details, which are optional, added to make the car look a little more interesting. A piece that looks like a hatch with hinges was glued on the top (decoration only, it does not open). The hatch itself and its latch are pieces of 0.5mm thick polystyrene, while the hinges were cut and sanded from the thicker 3.2 mm. On the rear there is a vent (picture 48), which had two side pieces of the L-shaped strips about 1.5 cm long which for the base for the slats to be glued to, as well as the part of the frame of the vent. The slats were strips 2mm wide, cut from the 0.5mm sheet. I glued tiny triangular pieces from the 3.2mm sheet, one on each of the L-shaped sides. This pair of triangles were used to anchor the top slat while it was glued with the model glue. I then repeated gluing a pair of tiny triangles with a single slat, ne under the other, as close as possible, until the vent had 6 slats close together but not touching. I used two more slats to give the vent a piece across the top and bottom to finish the frame. Lastly, I cut two pieces of tubing about 1.5 cm long each. For these I cut a rectangle of 3.2mm polystyrene that was more than big enough to cover the end of the tubing, and sanded down one end and the sides to give them a rounded look before gluing one on each end of each tube (picture 48) These were then mounted on the rear as well. These look like they could be external storage, or maybe some sort of fuel cell.

Conclusion

Arduino RC Vehicular Combat Game: Sneak Attack | 3 of 4 videos
UnderHood.jpg
UnderBack.jpg
UnderTop.jpg

Overall, I am quite pleased that the car works as intended. And I am pleased with the final result of the body considering it was made by hand. I didn’t have a lot of ideas of what details to put on the body, but the vent and fuel cells on the back turned out all right.


One thing I would change, I wish I made the car more modular. For example, I could use much of this car if I wanted to say, make a GPS guided car, but as the car is now switching to different components would not be as easy as it could be. The photodiodes are glued to the body, and cannot be easily removed and reinstalled. Plus, I would want to keep the motor driver, but not the large-ish MP3 player but now the “socket” for that is hardwired in. Or there isn’t an easy way to add other sensors for a line-following car, etc. 


Anyway, thank you for finishing this long Instructable, it certainly was a lot. However, I hope that I have included enough information for others who may be willing to try making this. It was a lot of fun to make and I think the sound effects make it an exciting game to play.