Toll Tax System using Arduino: Ultrasonic Sensor with Servo Motor

Toll Tax System Project:

Hello to all readers, our goal is to create a Toll Tax System using Arduino, Ultrasonic Sensor, and Servo Motor. The steps to create an automated toll tax system with an Arduino Uno will be outlined in this article. We provide step-by-step instructions along with comprehensive explanations of the code and circuit diagram. Opting for this project is an excellent choice if you’re considering a science fair project.

While I have primarily focused on intermediate and advanced level projects, there is an increasing demand from novices and hobbyists for easier tasks. Thus, I have devised this straightforward concept. Ultrasonic sensors and Servo motors are especially favored, especially by those new to the subject.

This project will allow you to improve fundamental skills such as identifying vehicles using an ultrasonic sensor and operating a Servo motor to lift a barrier.

Before proceeding with the construction phase of our project, it is crucial to have a clear understanding of the toll tax system, which is also referred to as the toll plaza stopping system.

Do you recall the initial visit you made to a toll booth? What new approach did they employ to halt vehicles for fundraising purposes? Our goal is to replicate that precise system, but on a reduced size.

This job requires accurately duplicating the vehicle-stopping system commonly found at toll plaza centers. This project was influenced by real-life toll systems that employ barriers to automatically stop vehicles activated by sensors or manual buttons.

In our situation, we are utilizing an HC-SR04 ultrasonic distance sensor to detect obstacles, which are vehicles. We are utilizing a small servo motor to raise the barrier. This is the essence of the project. Next, we will begin the construction phase.

Materials required to build automated toll system

Components and Materials Used:

1. Arduino Uno featuring the ATmega328P microcontroller.
2. HC-SR04 Ultrasonic Sensor.
3. Plastic Geared Micro Servo.
4. Single Strand Wire (substituting jumper wires).
5. Mini Breadboard.
6. Lithium Ion Battery with a protective case.
7. A few drops of superglue.
8. Arduino Programming Cable.
9. Arduino Integrated Development Environment (IDE).
10. A piece of popsicle stick.

Additional Tools and Components:

– Top Arduino Sensors.
– Super Starter Kit for Beginners.
– Digital Oscilloscopes.
– Variable Power Supply.
– Digital Multimeter.
– Soldering Iron Kits.
– Portable PCB Drill Machines.

Please be aware that these are affiliate links, and I may receive a commission if you choose to purchase these components via these links. Your support is greatly appreciated!

Circuit Diagram of toll system:

The circuit diagram for the Toll System is straightforward, with all connections easily visible.

Micro servo connections:

If you’re not familiar, take a look at the plastic geared micro servo depicted in the image above. The kit contains plastic gears and the servo horns are equipped with a holder/barrier made of a popsicle stick.

When it comes to the connections, we are utilizing the D9 pin on the Arduino Uno board, which serves as a PWM (Pulse Width Modulation) pin. This shows that signals for the micro servo are transmitted from the D9 pin in the form of pulses.

Since the micro servo’s signal input is linked to the D9 pin, we will utilize the Gnd and Positive pins to attach to the positive and negative pins on the breadboard power rails.

Now the servo connections have been completed. Next, we will examine the fundamental functions and connections of the ultrasonic sensor.

The ultrasonic sensor, HC-SR04, also referred to as the ultrasonic distance sensor, consists of four pins. The pins are labeled as Vcc, Trig, Echo, and Gnd. Usually, we connect the Vcc and Gnd pins to the breadboard’s positive and negative rails, while the Trig and Echo pins are linked to Arduino board’s D5

Functions of Ultrasonic sensor

The picture shows the appearance of the HC-SR04 sensor. This visual representation shows two distinct circular patterns.

These circles work as both the sender and recipient devices. When powered, the sensor emits ultrasonic signals from one side, which travel a set distance of 15 centimeters. The signals bounce back to the receiver if there are any obstacles on the route.

One of the uses of this small module is pertinent to our project.

In our project, we use vehicles as obstacles. In case the sensor detects signals from obstacles, it will instruct the micro servo to move upwards and remain in that position for a specific duration (as specified in the code) before returning to its initial state.

Through careful observation, the letters “T” and “R” can be identified at the boundaries of the sensor, showing where the transmitter and receiver components are located.

Our circuit setup for this project is now finished.

Pro Tip: For a tidier and neater appearance of both the circuit and the project, I highly recommend using single-strand wires instead of jumper wires to prevent unnecessary wire clutter.

Here’s a visual representation of the ultrasonic sensor assembly.

Most of the wires are carefully hidden inside the enclosure for a neat appearance. More precisely, the power input cables for the ultrasonic sensor are carefully placed behind the Arduino Uno. I used some small pieces of double-sided adhesive tape to attach the Arduino Uno to the breadboard.

When the micro servo is added to this arrangement, the final setup will look similar to the illustration provided.

It is crucial to note that we need a lithium-ion battery to supply a steady 3.7V DC power for our project since we are not using power from a USB connection.

I used a battery holder with pre-installed wires to simplify the connection process. For increased simplicity, I connected the ends of jumper wires to these battery leads, enabling easy attachment and removal of the power supply to the breadboard power rails.

Please be careful and do not turn on your project until you have uploaded the required code to the Arduino board.

Code for Arduino automatic barrier for toll

#include<Servo.h>
Servo myservo;
const int trigPin=3;
const int echoPin=5;
long tmeduration;
int distance;
void setup() {
myservo.attach(9);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
Serial.begin(9600);

}

void loop() {
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
tmeduration=pulseIn(echoPin,HIGH);
distance=(0.034*tmeduration)/2;
if(distance<=10){
myservo.write(90);
}
else{
myservo.write(0);}
Serial.print(“distance:”);
Serial.println(distance);
delay(1);
}


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top