The Fire Truck

by ghinelle in Circuits > Arduino

192 Views, 0 Favorites, 0 Comments

The Fire Truck

20230124_105433.jpg

My name is Ghinelle Rankine, and I'll be creating a fire truck. The aim of this survey is for the fire trucks to be able to go forward and backward, as well as turn right and left. There will be red and blue LED flashing on this fire vehicle to simulate an emergency. As a result, employing both red and blue lights helps to inform all motorists. Like a real fire truck. A siren will also sound. There will be two push buttons: one that activates the siren and flashes the emergency light, and one that shuts off the siren and light.

Reasearch

Before starting this project, I went through previous Instructables for ideas, but I couldn't find any. Then I recall the television series 911, which served as my inspiration. I have always been fascinated by fire trucks. I said, "Why not simply make a fire truck?" and then I started to watch a YouTube video of someone making an Arduino fire truck. Then I got to thinking about adding a siren, an emergency light, and the ability to drive forward and backward to my fire truck. This is where I found the inspiration for this project.

Materials

  1. Solderless Breadboard (1)
  2. LEDs (3) red and (3) blue
  3. 1 Resistor 10K ohm (6)
  4. Ultrasonic distance sensors (1)
  5. Push button switch (2)
  6. Piezo buzzer (1)
  7. Potentiometer (1)
  8. DC motor (1)
  9. L293NE chip (1)
  10. Wires

Wiring

2023-01-23 (2).png
2023-01-25 (2).png
  • Connect Power

The first step in connecting the VCC and GND from the Arduino to the breadboard is to apply ground and power since the components need both to function properly.

  • Led and Piezo buzzer

To begin, I wire the LEDs to the Arduino and connect the resistor to it; otherwise, the unrestricted current will quickly burn out the LED. Lower resistor values allow more current to pass, making the LED brighter. Higher resistor values restrict current flow, making the LED dimmer. The short LEDs connect to the ground side. The piezo buzzer is then added to produce the siren sound of my fire truck. I added two pushbuttons, one to activate the siren and the other to deactivate them. A3 and A2 are connected to the Arduino pins there.

  • L293D chip and potentiometer

The L293D chip, which has 16 pins, is used to instantly control the two sets of DC motors in any direction. It allows the DC motor to drive in any direction. I powered the chip, added inputs 4 to 10 on the Arduino, output 4 (which powers the motor), provided the pin grounds, input 3 (which powers the motor), enable 3, 4, and pin 11, enable 1, 2, and pin 5, and input 1 (which powers the key), among other operations. The potentiometer, which is used to measure the motor speed, is then added. I connect the middle of the potentiometer pin to the Arduino's analog pin 0 (A0), and the other two pins to +5V and GND.

  • Ultrasonic distance sensors

Following that, the ultrasonic distance sensors are installed. To determine distance, this component uses ultrasonic waves. The sensor head generates an ultrasonic pulse, which is then detected after being reflected back from the object without making direct contact with it. The distance sensors have four colors. TRIG (Trigger) pin is used to trigger ultrasonic sound pulses, the ECHO pin generates a pulse when the reflected signal is received, and GND should be connected to the Arduino's ground. VCC is the device's power source.

Code (variables)

2023-01-25 (3).png

To begin the code the variables are the initial part of the code. This will allow you to control the Arduino's pins. The variables ensure that the code runs without error.

Setup Function - Code

2023-01-25 (7).png

Now that I've done the first steps, I'll begin creating the setup code. This function is the first to run in the sketch, and it only runs once. It usually contains statements that set the pin modes of the Arduino to OUTPUT and INPUT. Now that I've completed the setup function, I'll go on to the more complex component of the code, the loop function.

Void Code for Sound and Motors

2023-01-25 (11).png
2023-01-25 (12).png

The siren's tone and the fire truck's movement are controlled by this void, which is another essential part of the code. One positive lead and one negative lead are typically all that a DC motor has. The motor has an opposite-rotation capability. The buzzer produces sound when an electric current is sent through it. The buzzer is a device that produces an audible tone when an external voltage is applied. This output can either sound like a beeping or a buzzing.

Void Color and Void On/off

2023-01-25 (14).png

This code controls the function that allows the led to turn on by sending a HIGH signal to one of the Arduino's pins. To turn off the LED, a LOW signal must be sent to the pin. A LED only allows electricity to flow through it in one direction, thus attaching it backward will not work. To make the LED dimmer, I have to increase the resistance. An LED has two leads, often known as legs. The anode is the longer leg, which is a positive. The cathode is the shorter leg, which is negative. In a circuit, pushbuttons connect two points. If I hold the two contacts together, a switch will turn on and allow electricity to flow through the circuit. As soon as the button is let go, the connection will end.





Void Loop Function- Code

2023-01-25 (5).png

The majority of the Arduino sketch is executed here. The program begins immediately after the opening curly bracket, continues until it encounters the closing curly bracket, then jumps back up to the first line of the loop function and begins again. The void loop method runs continuously until the Arduino is turned off. The void loop routines typically manipulate the Arduino's, for instance: Write a HIGH or LOW to a particular pin, along with the information gathered from them. My code will repeatedly run if I use the void loop. You will encounter an error if you attempt to compile code that is missing one of those functions.