Ambulence

by 1023268 in Circuits > Arduino

39 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 - $3.00

2 × 555 Timer IC - $2.00 each

1 × Capacitor, 2.2µF - $0.50

6 × Diode, 1N4148 - $0.10

2 × LED, Red - $0.50

2 × LED, Blue - $0.50

1 × Resistor, 1kΩ (R1) - $0.20

1 × Resistor, 22kΩ (R2) - $0.20

2 × Resistor, 4.7kΩ (R3, R4) - $0.20

6 × Resistor, 470Ω (R5, R6, R7, R8, R9, R10) - $0.20 each

1 x Distance sensor - $5

1 x IR sensor - $2

1 x H-Bridge - $5

1 x Buzzer - $2

2 x Resistor, 330 ohm - $0.32

1 x Arduino Uno - $20


Use Amazon and Digikey

The Car

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

Arduino Uno

Arduino is an open-source microcontroller platform for developing and prototyping interactive electronic projects. It's basically a small programmable circuit board that may be connected to sensors, motors, lights, and other devices. The device senses and controls the physical world. Quite simple to work with for a novice, it is programmed using a language similar to C/C++. It is highly used in hobby electronics, robotics, and automation projects due to its low cost, flexibility, and large community support online.


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, Digital Pin 9.


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
0.jpg

555 - timer

Brief summary: The 555 timer is an integrated circuit acting as a timing device, used for the production of accurate time delays or oscillations. It works by charging and discharging a capacitor through resistors while offering voltage points on 1/3 and 2/3 of supply voltage to switch its output. In the astable mode, the 555 timer toggles between high and low states continuously, thus producing a square wave. These are ideal in applications like blinking LEDs. The timer can also work in monostable mode-for one-shot pulse-and in bistable mode Flip-Flop, making the device very adaptable for use in several kinds of electronic projects.


Steps to Build the Circuit

Place Two 555 timer ICs in the breadboard, keeping some distance between them.

Connection of the Power Pins of the IC:

Connect jumper wires from the positive bus to the pin #8 of the IC.

Hook up the pin #4 to the pin #8 on both the IC's to turn ON the IC

Configure the Timing Circuit:

Connect the pin #2 to the pin #6 on both the IC.

Place a 1MΩ resistor between the pin#2 and #3 on the both the IC.

Add a 1µF capacitor between pins 1 and 2 of each of the ICs. The positive lead of the capacitor goes to pin 2. Next, GROUND the ICs: pin 1 of each IC goes to the negative bus of the breadboard. Now add the LEDs: Place 68Ω resistors on pin 3 of each of the ICs.

Connect three red LEDs to one IC and three blue LEDs to the other IC, making sure the positive leads are connected to the same vertical line as the resistors.

LEDs to Opposite IC: Using jumper wires, connect the negative leads of the LEDs to pin 3 of the opposite IC.

Power the Circuit:

Connect the positive power lead with the positive bus, and the negative lead with the negative bus. Set your power supply to 9V, then test the circuit.

Flashing effect: The LEDs should go from red to blue in a flashing sequence of lights-emitting a police flashing light effect

The Design

0.jpg

Take a piece of card board

The the sides (enough to fit the two bread boards on top of each other with space)

Add a piece of card board to inside to serve as foundation for the card board on top.

Place the 555 timer circuit on the piece of cardboard.

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.

Bring the wires for the LEDs out and place the roof on top.

Then solder the LEDs to the wires and place them on the roof.

Paint the card board any way you like to resemble a ambulance.