Police Car Arduino
Hello and welcome to this instructable on how to create your very own police car! I got the inspiration to base my CPT after a police car after I built my own RC car a while back last year as a way to get into remote controlling. This time however, with the arduino it feels even more original and overall much more of a authentic project not just for me but anyone who uses this instructable. The following steps will guide you from the materials you will need to the coding and software of the car.
Step 1: Your Materials
Materials and supplies needed for this project will be the following:
Quantity | Material
6 | 1kOhm resistor
2 | red LED's
2 | blue LED's
1 | battery (5volts)
1 | DC motor
1 | Arduino UNO R3
1 | Piezo element
1 | 250kOhm potentiometer
1 | NPN transistor
1 | Breadboard (optional)
Step 2 : Adding the Motor and Potentiometer
First, you will need to sort out your materials neatly, add the arduino and the breadboard. Layout should be horizontal to have enough room for the rest of the project. Second, add the DC motor, 1 resistor, potentiometer along with the 5 volt battery in. Next add the NPN transistor in the mix. The next part is the wiring which is crucial and must be done correctly, negative and positive wiring from the battery to the motor and breadboard is key. Make sure your potentiometer has its wiring correct from the terminals and wiper or else it will not work. Terminal 1 must be connected to the negative, terminal 2 to the 5V pin in the arduino and the wiper to pin A0. Once this is complete check over the NPN transistor to make sure it has the resistor as well as correct wiring for its emitter and collector. (collector from the dc motor, emitter from the battery). Finally the remaining part is adding the wiring to pin 5 in the arduino.
Step 3 : Software for the Motor
As seen in the image attached, this is the loop for the motor and potentiometer to work properly however it needs two defines, one define for output as it will be the value shown on the serial monitor and one define for pin 5 which is the motor itself.
Step 4: Piezo and LED's
Now for the Piezo and LED's the wiring is much less complicated than previously as all you need to do is arrange the wiring horizontally, and add a resistor to the anode side of the LED's and run the wires to pins 11 to 8 (if you do not wish to use all 4 leds, 2 pins and 2 leds will also display the pattern just not flashing constantly with the sound of the piezo). The cathode side will connect to the GND pin in the arduino. Now for the Piezo, add a resistor to the negative side and run the wiring to pin 7 (I made this on purpose as there is a split between pins 8 and 7, this makes wiring easier to view as all the LED pins are on the left and the motor and piezo are on the right.)
Step 5: Software for Siren
The code above has all the comments and instructions already to help you do this on your own as well as it teaches you what the code is doing. (Millisecond delays, when the LED's are on/off) In addition to this code, you will need to define pins 11-7 for LED's and Piezo. Make sure to name your second loop something else as commonly I made the mistake of the names being the same and the code not running properly.
Want to Build It in Real Life? Here Are Some Tips
If you wish to build this project for yourself use, make sure to purchase a soldering kit with an soldering iron and wire as well as protective gloves and goggles. Always make sure to never be directly above your work as you can inhale the harmful fumes! Exercise caution as the solder can reach very high temperatures and always work in a well lit environment. Make sure all your wiring is neat and is possible colour coded to help you identify it easily. Finally, the most important ... have fun!