{"id":12572,"date":"2020-04-21T03:40:20","date_gmt":"2020-04-21T07:40:20","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=12572"},"modified":"2024-10-30T03:31:03","modified_gmt":"2024-10-30T07:31:03","slug":"arduino-project-remote-based-toll-gate-and-automatic-parking-indicator-system","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/arduino-project-remote-based-toll-gate-and-automatic-parking-indicator-system\/","title":{"rendered":"Arduino project &#8211; Remote based toll gate and automatic parking indicator system"},"content":{"rendered":"<p>This post details about building a wireless toll gate and an automatic parking indicator system using Arduino. It will help anyone (including a beginner) who is interested to try their hands-on building and testing an Arduino project using IR remote \/ receiver, Ultrasonic sensor and servo motor.<\/p>\n<hr \/>\n<h3>Project brief<\/h3>\n<p>The idea is, When a vehicle approaches the toll gate, a button will be pressed in the IR Remote. This will open the toll gate. The vehicle will now gain entry and will proceed towards the parking. As it gets closer to the parking,\u00a0 the Red LED will turn ON and simultaneously Green LED will turn OFF. This will indicate that the parking is now occupied. When the vehicle leaves the parking, the parking will become available again. This will be indicated by the system returning to its default setup. That is, Green LED will be turned ON and on the press of another button in IR Remote the toll gate will be closed.<\/p>\n<p>You could refer to our tutorials, to get a hang on <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-decoding-of-ir-receiver\/\" target=\"_blank\" rel=\"noopener\">IR Remote \/ Receiver<\/a>, <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-ultrasonic-sensor\/\" target=\"_blank\" rel=\"noopener\">Ultrasonic sensor<\/a> and <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-servo-motors\/\" target=\"_blank\" rel=\"noopener\">Servo motor<\/a>.<\/p>\n<hr \/>\n<p>This remote based tollgate and automatic parking indicator system is made up of two parallel circuits. One is the toll gate circuit and another being the parking indicator circuit. I had used the Arduino UNO and a breadboard for building this system from the\u00a0<a href=\"https:\/\/www.amazon.in\/dp\/B01KNR581U\/ref=ox_ya_os_product\" target=\"_blank\" rel=\"noopener\">Arduino starter kit<\/a>. Other requirements pertaining to each of these circuits are detailed below.<\/p>\n<hr \/>\n<h3>Build the toll gate circuit<\/h3>\n<p><strong>Components required to build the toll gate circuit :<\/strong><br \/>\n&#8211; IR remote\/ receiver<\/p>\n<p>&#8211; Servo motor<\/p>\n<p>&#8211; A few jumper wires<\/p>\n<p><strong>Wiring details of the toll gate circuit :<\/strong><br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/05\/latest_toll_gate_circuit.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8810 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/05\/latest_toll_gate_circuit.png\" alt=\"Toll gate wiring\" width=\"904\" height=\"374\" \/><\/a><\/p>\n<p><strong>Arduino sketch:<\/strong><\/p>\n<p>The Arduino sketch invokes a Serial Monitor to keep us informed of the workflow at runtime.<\/p>\n<pre>#include\u00a0&lt;IRremote.h&gt; \/\/ Load the IRremote library\r\n#include\u00a0&lt;Servo.h&gt; \/\/ Load the servo library\r\n\u00a0\r\nint IR_receiving_pin = 9; \/\/ IR receiver pin connected to Arduino pin 9\r\nint Serv_pin = 11; \/\/ Servo motor pin connected to Arduino pin 11\r\n\u00a0\r\n\/\/ Variables to hold the servo motor's rotation angle at Open and Close positions\r\nint toll_open_position = 180 ;\r\nint toll_close_position = 90 ;\r\n\u00a0\r\n\/\/ Decoded values on button press\r\nlong decoded_value_for_button_0 = 16738455;\r\nlong decoded_value_for_button_1 = 16724175;\r\n\u00a0\r\nIRrecv irrecv(IR_receiving_pin); \/\/ Create an IR receiver object and attach the associated input pin\r\nServo Serv_obj; \/\/ Create a servo object\r\n\u00a0\r\ndecode_results IR_decoded_value; \/\/ Initialize a variable to hold the decoded IR receiver value\r\n\u00a0\r\nvoid setup() {\r\n\/\/ put your setup code here, to run once:\r\n\u00a0\r\nSerial.begin(9600); \/\/ Start the Serial monitor\r\nSerial.println(\"Enabling IR Receiver\");\r\nirrecv.enableIRIn(); \/\/ Start the IR receiver\r\nSerial.println(\"Enabled IR Receiver!\");\r\n\u00a0\r\nServ_obj.attach(Serv_pin); \/\/ Attach the pin associated with the Servo motor to the servo object\r\nServ_obj.write(toll_close_position); \/\/ Default to toll gate - close position\r\nSerial.println(\"You are at the Toll gate! Press button 1 to OPEN gate.\");\r\n}\r\n\u00a0\r\nvoid loop() {\r\n\/\/ put your main code here, to run repeatedly:\r\n\u00a0\r\nif (irrecv.decode(&amp;IR_decoded_value)) \/\/ Checks if a signal is received and decodes it\r\n{\r\n\/\/ Circuit 1: Toll gate\r\nif (IR_decoded_value.value == decoded_value_for_button_1)\r\n{\r\nSerial.println(\"Button 1 pressed. Open toll gate !\");\r\nServ_obj.write(toll_open_position);\r\n}\r\nelse if (IR_decoded_value.value == decoded_value_for_button_0)\r\n{\r\nSerial.println(\"Button 0 pressed. Close toll gate !\");\r\nServ_obj.write(toll_close_position);\r\n}\r\nirrecv.resume(); \/\/ Continue to receive the next input\r\n}\r\n\u00a0\r\ndelay(1000);\r\n\u00a0\r\n}\r\n<\/pre>\n<hr \/>\n<h3>Build the parking indicator circuit<\/h3>\n<p>The parking indicator circuit should be built in parallel to the toll gate circuit on the breadboard.<\/p>\n<p><strong>Components required to build the parking indicator circuit :<\/strong><br \/>\n&#8211; Ultrasonic sensor<\/p>\n<p>&#8211; Red LED and \u00a0Green LED<\/p>\n<p>&#8211; 220 ohms resistors(2)<\/p>\n<p>&#8211; A few jumper wires.<\/p>\n<p><strong>Wiring details of the complete system :<\/strong><br \/>\n<a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/05\/latest_complete_circuit.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8810 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/05\/latest_complete_circuit.png\" alt=\"Complete system wiring detail\" width=\"904\" height=\"374\" \/><\/a><\/p>\n<p><strong>The complete Arduino sketch:<\/strong><\/p>\n<pre>\/*\r\nProgram to test the toll gate and parking indicator circuits.\r\n*\/\r\n\u00a0\r\n#include &lt;IRremote.h&gt; \/\/ Load the IRremote library\r\n#include &lt;Servo.h&gt; \/\/ Load the servo library\r\nint IR_receiving_pin = 9; \/\/ IR receiver pin connected to Arduino pin 9\r\nint Serv_pin = 11; \/\/ Servo motor pin connected to Arduino pin 11\r\nint echo_pin = 6; \/\/ Ultrasonic sensor's echo pin connected to Arduino pin 6\r\nint trigger_pin = 7; \/\/ Ultrasonic sensor's Trig pin connected to Arduino pin 7\r\nint Green_LED_pin = 2; \/\/ Green LED connected to Arduino pin 2\r\nint Red_LED_pin = 4; \/\/ Red LED connected to Arduino pin 4\r\n\r\nfloat ping_time; \/\/ Time for ping to travel from sensor to target and return\r\nlong distance_in_cm; \/\/ Distance to the target in cms\r\n\r\n\/\/ Variables to hold the servo motor's rotation angle at Open and Close positions\r\nint toll_open_position = 180 ;\r\nint toll_close_position = 90 ;\r\n\r\n\/\/ Decoded values on button press\r\nlong decoded_value_for_button_0 = 16738455;\r\nlong decoded_value_for_button_1 = 16724175;\r\n\r\nIRrecv irrecv(IR_receiving_pin); \/\/ Create an IR receiver object and attach the associated input pin\r\nServo Serv_obj; \/\/ Create a servo object\r\n\r\ndecode_results IR_decoded_value; \/\/ Initialize a variable to hold the decoded IR receiver value\r\n\r\nvoid setup() {\r\n\/\/ put your setup code here, to run once:\r\n\u00a0\r\nSerial.begin(9600); \/\/ Start the Serial monitor\r\nSerial.println(\"Enabling IR Receiver\");\r\nirrecv.enableIRIn(); \/\/ Start the IR receiver\r\nSerial.println(\"Enabled IR Receiver!\");\r\n\u00a0\r\nServ_obj.attach(Serv_pin); \/\/ Attach the pin associated with the Servo motor to the servo object\r\nServ_obj.write(toll_close_position); \/\/ Default to toll gate - close position\r\nSerial.println(\"You are at the Toll gate! Press button 1 to OPEN gate.\");\r\n\u00a0\r\npinMode(echo_pin,INPUT); \/\/ Set ultrasonic sensor's echo pin as an input pin\r\npinMode(trigger_pin,OUTPUT); \/\/ Set ultrasonic sensor's trig pin as an output pin\r\npinMode(Green_LED_pin,OUTPUT); \/\/ Set GREEN LED as an output pin\r\npinMode(Red_LED_pin,OUTPUT); \/\/ Set RED LED as an output pin\r\n}\r\n\r\nvoid loop() {\r\n\/\/ put your main code here, to run repeatedly:\r\n\u00a0\r\nif (irrecv.decode(&amp;IR_decoded_value))\u00a0 \/\/ Checks if a signal is received and decodes it\r\n{\r\n\/\/ Circuit 1: Toll gate\r\nif (IR_decoded_value.value == decoded_value_for_button_1)\r\n{\r\nSerial.println(\"Button 1 pressed. Open toll gate !\");\r\nServ_obj.write(toll_open_position);\r\n}\r\nelse if (IR_decoded_value.value == decoded_value_for_button_0)\r\n{\r\nSerial.println(\"Button 0 pressed. Close toll gate !\");\r\nServ_obj.write(toll_close_position);\r\n}\r\nirrecv.resume(); \/\/ Continue to receive the next input\r\n}\r\n\u00a0\r\ndelay(1000);\r\n\u00a0\r\n\/\/ Circuit 2:Parking Indicator\r\n\/\/ Generate a ping by triggering the ultra sonic sensor\r\ndigitalWrite(trigger_pin, LOW); \/\/ Set the trig pin low\r\ndelayMicroseconds(2000); \/\/ Wait for the signal to settle in this state\r\ndigitalWrite(trigger_pin, HIGH); \/\/ Set trig pin high\r\ndelayMicroseconds(15); \/\/ Wait in this high state\r\ndigitalWrite(trigger_pin, LOW); \/\/ Ping would have been sent now\r\n\u00a0\r\nping_time = pulseIn(echo_pin, HIGH); \/\/ ping_time is presented in microseconds\r\n\u00a0\r\ndistance_in_cm = convert_microsecondsToCentimeters(ping_time); \/\/ Calculate distance in cms\r\n\u00a0\r\nif (distance_in_cm &gt;7)\r\n{\r\ndigitalWrite(Green_LED_pin, HIGH);\r\ndigitalWrite(Red_LED_pin, LOW);\r\nSerial.println(\"Parking slot available!\");\r\ndelay(100);\r\n\u00a0\r\n}\r\nelse if (distance_in_cm &lt; 7 and distance_in_cm &gt; 0)\r\n{\r\nSerial.println(\"Distance of the vehicle:\");\r\nSerial.print(distance_in_cm);\r\nSerial.print(\"cm\");\r\nSerial.println();\r\ndigitalWrite(Green_LED_pin, LOW);\r\ndigitalWrite(Red_LED_pin, HIGH);\r\nSerial.println(\"Parking slot occupied!\");\r\ndelay(100);\r\n}\r\n\u00a0\r\ndelay(1000);\r\n}\r\n\r\nlong convert_microsecondsToCentimeters(long microseconds) {\r\n\/\/ The speed of sound is 340 m\/s or 29 microseconds per centimeter.\r\n\/\/ The ping travels out and back, so to find the distance of the\r\n\/\/ object we take half of the distance travelled.\r\nreturn microseconds \/ 29 \/ 2;\r\n}\r\n<\/pre>\n<hr \/>\n<p><b>A video recording of this project for your reference:<\/b><\/p>\n<div style=\"width: 640px;\" class=\"wp-video\"><!--[if lt IE 9]><script>document.createElement('video');<\/script><![endif]-->\n<video class=\"wp-video-shortcode\" id=\"video-12572-1\" width=\"640\" height=\"362\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/04\/Arduino_Tollgate_ParkingIndicator.mp4?_=1\" \/><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/04\/Arduino_Tollgate_ParkingIndicator.mp4\">https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2020\/04\/Arduino_Tollgate_ParkingIndicator.mp4<\/a><\/video><\/div>\n<hr \/>\n<p>I hope you enjoyed building and testing this remote based tollgate and parking indicator system with Arduino.\u00a0This system could be further enhanced by making use of wireless sensors to detect the presence of vehicles at the tollgate and operating the gates automatically.<\/p>\n<hr \/>\n<h3>Hire QA consultants from Qxf2 for your startup<\/h3>\n<p>Qxf2 understands the urgency of finding the right QA support for startups. We offer flexible, on-demand QA services that can step in immediately, helping you establish quality practices without delay. Check out our <a href=\"https:\/\/qxf2.com\/?utm_source=toll-gate-arduinos&#038;utm_medium=click&#038;utm_campaign=From%20blog\">quick QA solutions for startups<\/a> to get expert help when you need it most.<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>This post details about building a wireless toll gate and an automatic parking indicator system using Arduino. It will help anyone (including a beginner) who is interested to try their hands-on building and testing an Arduino project using IR remote \/ receiver, Ultrasonic sensor and servo motor. Project brief The idea is, When a vehicle approaches the toll gate, a [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159,117],"tags":[119],"class_list":["post-12572","post","type-post","status-publish","format-standard","hentry","category-arduino","category-hardware-testing","tag-arduino"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/12572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=12572"}],"version-history":[{"count":42,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/12572\/revisions"}],"predecessor-version":[{"id":22999,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/12572\/revisions\/22999"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=12572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=12572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=12572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}