Ambulence

by 1023268 in Circuits > Arduino

9 Views, 0 Favorites, 0 Comments

Ambulence

ac-ambulance.-full.jpg

This project involves the design and construction of a working miniature car modeled in the shape of an ambulance. The car will be equipped with an IR sensor, allowing it to be controlled remotely through infrared signals. The ambulance design will mimic a real-life emergency vehicle, complete with distinctive features such as flashing lights to enhance the realistic appearance. The remote control functionality will utilize infrared technology, whereby the car will be able to respond to specific commands for movement, turning, and stopping.

Supplies

1 × Battery, 9V

1 × 555 Timer IC

1 × CD4017 Decade Counter IC

2 × BC547 NPN Transistor

1 × Capacitor, 2.2µF

6 × Diode, 1N4148

2 × LED, Red

2 × LED, Blue

1 × Resistor, 1kΩ (R1)

1 × Resistor, 22kΩ (R2)

2 × Resistor, 4.7kΩ (R3, R4)

6 × Resistor, 470Ω (R5, R6, R7, R8, R9, R10)

1 x Distance sensor

1 x IR sensor

1 x H-Bridge

1 x Buzzer

1 x Resistor, 330 ohm

1 x Arduino Uno

The Car

Screenshot 2025-01-21 100154.png
0.jpg

Place the H-Bridge Motor Driver on the Breadboard: Position the motor driver module such that its pins are accessible on the breadboard. Connect the Power Supply: Connect the 9V battery positive wire to the motor power input on the H-Bridge, labeled as VCC or 12V. Connect the battery ground wire to the H-Bridge ground, GND. Connect the H-Bridge logic power pin, 5V or VCC, to the 5V output pin on the Arduino.

Connect the Arduino's ground to the breadboard's ground rail to share ground with the H-Bridge and the rest of the components. Connect the Motors: Connect the wires of motor 1 to the output terminals A (OUT1 and OUT2) on the H-Bridge. Connect the wires of motor 2 to the output terminals B (OUT3 and OUT4). Control Pins Connection:

Connect the H-Bridge input pins (IN1, IN2, IN3, IN4) to the Arduino's digital PWM pins:

IN1: Arduino Digital Pin 5

IN2: Arduino Digital Pin 6

IN3: Arduino Digital Pin 9

IN4: Arduino Digital Pin 10

Connect the H-Bridge Enable pins (EN1 and EN2) as well:

EN1: Connect to Arduino Digital Pin 3 for PWM control of motor 1.

EN2: Connect to Arduino Digital Pin 11 for PWM control of motor 2.

Connect the IR Sensor Module:

Place the IR sensor module on the breadboard. Connect the VCC pin of the IR sensor to the 5V pin on the Arduino. Next, connect the GND pin of the IR sensor to the ground rail of the breadboard. Connect the output signal pin of the IR sensor to an Arduino digital input pin. For instance, Digital Pin 7. Finalize Connections: Connect the Arduino's GND to the breadboard ground.

Double-check that all power, ground, motor, and control signal connections match the H-Bridge and IR sensor pinouts.

The Code

Use this code

#include <IRremote.h>

int RECV_PIN = 9;

IRrecv irrecv(RECV_PIN);

decode_results results;


const int buzzer = 4;

int trig = 7;

int echo = 8;

int m1a = 5;

int m1b = 3;

int m2a = 10;

int m2b = 13;

const int distanceThreshold = 10;

void setup()

{

Serial.begin(9600);

Serial.println("Enabling IRin");

irrecv.enableIRIn();

Serial.println("Enabled IRin");

pinMode(3, OUTPUT);

pinMode(5, OUTPUT);

pinMode(10, OUTPUT);

pinMode(9, INPUT);

pinMode(13,OUTPUT);

pinMode(7,OUTPUT);

pinMode(8,INPUT);

pinMode(5,OUTPUT);

digitalWrite(buzzer, LOW);

}


void loop()

{

digitalWrite(trig, LOW);

delayMicroseconds(2);

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);

long distance = getDistance();

Serial.print(distance);

if (distance <= distanceThreshold && distance > 0) {

digitalWrite(buzzer, HIGH);

}

else {

digitalWrite(buzzer, LOW);

}

if (irrecv.decode(&results)) {

Serial.println(results.value, HEX);

irrecv.resume();

if(results.value == 0xC26BF044){

//forward

move(1,0,0,1);

}

else if (results.value == 0x53801EE8){

//right

move(1,0,0,0);

}

else if (results.value == 0xC4FFB646){

//back

move(0,1,1,0);

}

else if (results.value == 0x758C9D82){

//left

move(0,0,0,1);

}

else if (results.value == 0xF4BA2988){

move(0,0,0,0);

}

}

delay(100);


}


void move(int m1a, int m1b, int m2a, int m2b){

digitalWrite(5,m1a);

digitalWrite(3,m1b);

digitalWrite(10,m2a);

digitalWrite(13,m2b);

}


long getDistance() {

digitalWrite(trig, LOW);

delayMicroseconds(2);

digitalWrite(trig, HIGH);

delayMicroseconds(10);

digitalWrite(trig, LOW);



long duration = pulseIn(echo, HIGH);


long distance = duration / 74 / 2;


return distance;

}

The Lights

0.jpg
  1. Start by placing the 555 Timer IC and CD4017 IC on the breadboard with an appropriate distance between them for easy connections.
  2. Connect the VCC (pin 8 of the 555 timer and pin 16 of the CD4017) and GND (pin 1 of the 555 timer and pin 8 of the CD4017) to the positive and ground rails of the breadboard.
  3. Connect the RESET (pin 4 of the 555 timer) to the positive rail, and connect MR and CI (pins 15 and 13 of the 4017 IC) to the ground rail.
  4. Place the transistors on the breadboard and connect their collectors to the 9V supply through the corresponding LEDs and resistors.
  5. Wire the 555 Timer IC as shown in the schematic, using the R1, R2, and C1 to set the time interval of astable oscillation.
  6. Arrange the 1N4148 diodes, according to the schematic, ensuring that the signals from the CD4017 correctly drive the transistors Q1 and Q2. And connect the resistors R7, R8, R9, R10.
  7. Once the circuit is connected, power it up and the red LEDs should flash three times, followed by the blue LEDs flashing three times, repeatedly.

The Design

0.jpg
  1. Take a piece of card board
  2. The the sides (enough to fit the two bread boards on top of each other with space)
  3. Add a piece of card board to inside to serve as foundation for the card board on top.
  4. Place the 555 timer circuit on the piece of cardboard.
  5. Take another piece of cardboard the will be used as the roof and poke holes in it so that you can bring the leds out to see.
  6. Bring the wires for the LEDs out and place the roof on top.
  7. Then solder the LEDs to the wires and place them on the roof.
  8. Paint the card board any way you like to resemble a ambulance.