Home > Driving Displays, Driving Motors, Exploring Ideas > Arduino Parking Lot ( Filled )

Arduino Parking Lot ( Filled )

Wiring diagram:

Here is the code:

Arduining.com 08 JUL 2012
Code used in the production of the Youtube material.

#include <Servo.h>
Servo myservo;  // create servo object to control a servo

#define ServoM    12        //Connected to the servo motor.
#define Bright    11        //servo library disable PWM on pins 9 and 10.
#define Exit      9         //Pin connected to the EXIT button.
#define In        8         //Pin connected to the IN button.

#define BarLow    177       //Low position of the barrier.
#define BarUp     95        //Up position of the barrier.
#define CAPACITY  8         //Capacity of the parking lot.
#define INTEN     80        //Display intensity %

//Pins conections to segments (cathodes).
#define  segA  0
#define  segB  1
#define  segC  2
#define  segD  3
#define  segE  4
#define  segF  5
#define  segG  6

//Array with the segments to represent the decimal numbers (0-9).
byte segments[10] = {
// pgfedcba  <--- segments
  B00111111, // number 0
  B00000110, // number 1
  B01011011, // number 2
  B01001111, // number 3
  B01100110, // number 4
  B01101101, // number 5
  B01111101, // number 6
  B00000111, // number 7
  B01111111, // number 8
  B01101111  // number 9

void setup(){
  myservo.attach(ServoM);          // attaches the servo.

  pinMode(Exit, INPUT);           // set "EXIT" button pin to input
  pinMode(In, INPUT);             // set "IN" button pin to input
  digitalWrite(Exit, HIGH);       // Connect Pull-Up resistor.
  digitalWrite(In, HIGH);         // Connect Pull-Up resistor.
  myservo.write(BarLow);          //Barrier in the low position
//  delay(1000);

int  Available= 9;                    // Number of places available.

void loop(){
  if(Available != 0){
  if(Available != CAPACITY){

Put the segments according to the number.
void Display(int number){
byte segs =  ~segments[number];        //"~" is used for commom anode.

digitalWrite(segA, bitRead(segs, 0) );
digitalWrite(segB, bitRead(segs, 1) );
digitalWrite(segC, bitRead(segs, 2) );
digitalWrite(segD, bitRead(segs, 3) );
digitalWrite(segE, bitRead(segs, 4) );
digitalWrite(segF, bitRead(segs, 5) );
digitalWrite(segG, bitRead(segs, 6) );

See it in Youtube:

and how was done:

  1. Kim
    October 16, 2012 at 3:10 PM

    Nice! Why not use cap sense Library and use a small metallic plate at the entrance?
    Cheers Kim

    • October 16, 2012 at 9:35 PM

      Thanks, I’ll do some experiments using your idea.

  2. ghit86
    October 16, 2012 at 5:10 PM

    Goo job!

  3. Line96
    November 22, 2012 at 11:41 PM

    nice project. wanna ask, what material used to build the switch pad?

    • December 12, 2012 at 11:10 AM

      Aluminium foil, you can find it at the supermarket. Check the second video.

  4. December 19, 2012 at 6:26 PM

    Awesome project.

    Where did you get the servo rotor?

    • December 22, 2012 at 10:27 AM

      Amazon, Sparkfun, Robotshop, dealextreme, adafruit, Plolu, eBay,
      I have used all of them sucessfully…

  5. Maze1
    March 29, 2013 at 8:35 PM

    Nice Job!!! What kind of sensor did you use and how was it connected?

  6. March 31, 2013 at 7:25 AM

    hello can you email me the full program for your project im doing a similar project and I need some help

  7. April 16, 2013 at 1:26 PM

    Would it be possible to use two touch sensor for the entrance and exit?

  8. Márcia VR
    June 9, 2013 at 3:10 PM

    Gostei do seu projeto, mas fiquei com algumas duvidas… o material que vocẽ usou para colocar no piso do estacionamento é papel cartão?
    Estou iniciando meeessssmmmmoooo na área da robótica e preciso saber o nome dos pinos que você usou para plugar no clips…

    • June 9, 2013 at 4:14 PM

      Não falo muito portugués.
      -Yes is cardboard.
      -Look for “minigrabbers” in google images…
      Obrigado Márcia por visitar meu blog.

  9. Mc
    September 12, 2013 at 12:37 AM

    I don’t understand these lines…

    B00111111, // number 0
    B00000110, // number 1
    B01011011, // number 2
    B01001111, // number 3
    B01100110, // number 4
    B01101101, // number 5
    B01111101, // number 6
    B00000111, // number 7
    B01111111, // number 8
    B01101111 // number 9

    How to identify those “B00111111″???

    and this one” analogWrite(Bright,255*INTEN/100);”

    I hope you can somehow explain some lines on the code… I’m a newbie.

  10. September 12, 2013 at 2:58 PM

    An array of 10 bytes was declared and the name of the array is segments.
    byte segments[10] = { ….
    Then the array is filled with bytes in binary format (8 bits).
    The bit values correspond to the state of the segments a,b,c,d,e,f and g of the display to represent numbers from 0 to 9. Note that bit 7 is always 0 because the decimal point (p) is not used in this application.
    To change the intensity of the display, a PWM signal is used in the common of the display.
    “Bright” is the pin of the display where all the leds are connected (the common).
    when I said:
    #define Bright 11
    at the beginning of the code, it means that every time you see the word “Bright” in the code,
    it will be replaced by “11” before the code compilation.
    #define INTEN 80
    is used to change the display intensity.
    With this in mind:
    is the same as:
    The expression 255*INTEN/100 was used to specify INTEN as percentage.

    Hope it helps…

    • Leon Manuel Jimenez Soto
      May 9, 2014 at 9:38 AM

      thanks very much, you help me to!

    • don paulo
      March 6, 2015 at 11:49 PM

      is there a program for arduino uno using double seven segment display. i’m having a hardtime fixing my script.. please message me fast!

  11. October 28, 2013 at 4:15 PM

    hi there, could you do an example using a wireless RF remote

  12. October 28, 2013 at 4:16 PM

    love this project…so cool

  13. December 2, 2013 at 1:31 AM

    sir can we use a 16 segment led display in this project?

    • December 2, 2013 at 3:50 PM

      I see no problem with it. You’ll need the analog pins as digital outputs to drive all the segments.

      • December 3, 2013 at 8:12 PM

        how are we going to use that sir? sir can you give us the code that decreases the number of vehicle in the display everytime they exit?thank you sir more power

  14. December 9, 2013 at 6:29 AM

    sir can you please give us the materials and circuit diagram that you use in that project?thank you very much sir

  15. Denden
    January 15, 2014 at 1:42 AM

    hello, i have a problem with this part

    void loop(){

    it says ‘Display’ was not declared in this scope. what should i do?
    i just started using arduino TIA

    • Kamelio
      November 23, 2014 at 3:26 AM

      Could you solve your problem? I have the same trouble

      • November 26, 2014 at 6:41 PM

        Check that you have the function:
        void Display(int number){

        at the end of your sketch.

  16. nex
    February 4, 2014 at 5:11 AM

    Sir, i want to know the type of servo?

    • February 6, 2014 at 6:22 PM

      Hitech HS-55 or similar.

  17. May 17, 2014 at 7:16 PM

    que tipo de servomotor voy utlizar

  18. May 17, 2014 at 7:18 PM

    hello hear that type of servomotor is used

  19. murali
    July 18, 2014 at 3:15 AM

    instead of aluminium foil..,, can we replace with a push button switch..,,,???

    • July 18, 2014 at 3:30 PM

      Yes, actually the aluminium foil is acting as a switch.

      • September 8, 2014 at 11:02 AM

        Hello, what material used to build the switch pad?

  20. murali
    July 18, 2014 at 3:22 AM

    if we got to increase the number of cars in the lot (say 20)..,, what changes should me made.,, in program and displaying…,,

  21. Jeff Valerio
    July 29, 2014 at 3:29 AM

    Please reply, as I have problems with the 7 segment display, my 7 segment display is fully working but segment A or the upper segment is not lighting.

    I have reversed the code you used into:

    B1000000, // number 0
    B1111001, // number 1
    B0100100, // number 2
    B0110000, // number 3
    B0011001, // number 4
    B0010010, // number 5
    B0000010, // number 6
    B1111000, // number 7
    B0000000, // number 8
    B0010000 // number 9

    Using your schematic diagram with YOUR code, the lights are reversed, so I reverted the code into this, Because I’m using an anode 7 segment display. and its working but my problem is that the pin for segment A is not working. From my tests, the 7 segment display is working, my wires are working, the resistor is also working, the pins of the arduino are also working, Does disabling the PWM pins has something to do with this?

    Does this comment,

    //Pins conections to segments (cathodes).

    means the pin connection is for cathode only?

    Your fast reply is highly appreciated. Thanks in advance! :)

  22. Jeff Valerio
    July 29, 2014 at 3:32 AM

    PS.: Even with the 1s in the start of each array, (for the decimal point which is not in use in the code) the segment A or the topmost segment of the 7 segment display isn’t working. :( Please help. Thanks.

    • July 29, 2014 at 8:05 AM

      Try changing only the line:
      byte segs = ~segments[number];
      byte segs = segments[number];

  23. Leslie Ann Gonzales
    August 25, 2014 at 1:59 AM

    good afernoon sir, I’m curious about the aluminum foil. It is the switch pad right? How does it work? Can you explain how is it connected with the circuit. Thank you.

    • September 24, 2014 at 11:46 AM

      Common aluminum foil glued to cardboards.
      Minigrabber test leads to connected the paperclips to the Arduino.
      See the second video “The making…”

  24. Chinmay K
    September 16, 2014 at 11:30 AM

    Sir, can you please provide the sevro motor specifications.

    • September 24, 2014 at 11:29 AM

      The Hitech HS-55 was used in this project any standard or mini servo can be used, just do some experimentation to find the correct values to the UP and DOWN position of the barrier.

  25. murali
    September 24, 2014 at 9:14 AM

    dear sir,, i am murali. and I wonder if you can spare your precious time for me. We are doing this as our mini project. review seminars are on progress. if we may be asked a question like “why are you using arduino UNO only..?” what should we answer them..?
    please help us.. thanks in advance

    • September 24, 2014 at 11:25 AM

      Hi murali, you can use any Arduino compatible board like: UNO, Duemilanove, Leonardo, Due, Mini, NANO etc..

  26. Shazam
    October 1, 2014 at 9:07 AM

    I’ve encountered a problem. When the input is hold on 0 the count continuously decrease.

  27. October 28, 2014 at 5:33 PM

    what king of display did u used

  28. November 4, 2014 at 5:19 PM

    if I want to used 2 servos for this project one the entrance and the other one for the exit. would you tell me what kind of change I can do in the cade

    • November 26, 2014 at 6:45 PM

      It’s perfectly possible and a very good idea.
      You have to declare two servos:
      Servo barrierEntrance;
      Servo barrierExit;

      • asaad
        January 24, 2015 at 3:32 AM

        Hi dear
        Pls could you mention all the components that u used in this project
        With the specific name and details?
        Please i am waiting ur reply as soon as possible

  29. murali
    November 10, 2014 at 10:01 AM

    dear sir,, what are the limitations of this project??

  30. pooja parikh
    November 12, 2014 at 4:32 AM

    hallow sir, please send me a circuit operation and circuit diagram of this project

  31. murali
    November 12, 2014 at 12:49 PM

    Dear sir,. this is murali, We have completed this as our mini project. Today there was a expo, we have clearly demonstrated the project. During expo we came across with few situations

    1) The cars will be entering into the lot and the lot is filed. When the lot is filled, the vacant spaces are zero and no car is allowed to enter. Now, the power is gone. (we used adapter 12v, 1.5amps) and comes back. Then the seven segment display shows the maximum count, though the lot is filled. means the arduino is allowing the others cars to enter the lot.

    2) Now the another one, the car is ready to enter the lot. The car approaches the gate and gate opens up. Now the driver is in urgency and left. Though the car has not entered the lot, the count is decremented.

    3) Car reaches the gate, aluminium foil comes in contact and gate opens. Though the gate is open, the driver doesn’t enter. means when the aluminium foils are continue to remain in contact then the count keeps on decrements and after reaching zero the gate closes.

    4) when at a time two cars one after the other tries to enter the lot, then how can you prevent the overcrowding.?

    5) when two cars one leaves the lot and other enters, approaches the gate at same time. What will be the situation.?

    When we were asked questions, we were helpless and told them that this is a prototype version, if we are interested then we can go much deeper and come up with beautiful solutions.

    and we were are also asked

    6) when two aluminium foils come in contact, will arduino recieves a pulse or a electric signal.?

    7) How the arduino is providing 5v power suppy to servo motor.?

    8) Explain the architecture of arduino.?

  32. dj buena
    November 18, 2014 at 12:34 AM

    how an aluminum foil work?

  33. anz
    December 10, 2014 at 2:04 PM

    What sensors are used ?

  34. DEREK
    February 24, 2015 at 10:14 AM


  35. rachid
    March 23, 2015 at 11:37 AM

    hey sir,can I use mini srvomotor towerpro SG90 9G??

  36. pnn
    March 27, 2015 at 9:36 AM

    Hey, i want to connect the parking lot to a ultra sound sensor not a tipe of button, can you help pls?

  37. fade
    March 27, 2015 at 2:36 PM

    please i need the code

  38. April 19, 2015 at 11:15 PM

    What are the materials needed??

    • April 20, 2015 at 10:00 AM

      List of materials:
      -Arduino UNO
      -RC Micro Servo (Hitec HS-55 or similar)
      -7-Segment Display Common anode.
      -470 ohms resistors 1/4 w 5% (7)
      -Mini breadboard 170 points
      -cable jumpers Male-to-Male (14)
      -Solid wire AWG #22 (breadboard jumpers)
      -aluminum foil
      -paper clips (3)
      -Wooden Coffee Stirrer (the barrier)
      -White glue…

    • fade
      June 13, 2015 at 8:10 AM

      Can I do this project for 100 cars is not for … 8 cars will be on the amendment to the compiler code is not it? !

  39. April 21, 2015 at 9:15 PM

    What are the things you have used to attach with paper clip

    • April 22, 2015 at 12:49 AM

      Google: cable mini grabbers

  40. April 21, 2015 at 9:40 PM

    And send me the diameters of the base and the foil pad switch

  41. April 21, 2015 at 9:42 PM

    Can we use towerpro sg90 servo

    • April 22, 2015 at 1:03 AM

      towerpro sg90 servo is perfect.

  42. April 22, 2015 at 10:22 AM

    how yo made the foil switch

    • April 22, 2015 at 11:52 AM

      Cardboard and aluminum foil push pad:

      ********************* <—White glue
      ===================== <—Aluminum foil
      XXXXX……….XXXXXX <—Cardboard with the window
      ===================== <—Aluminum foil
      ********************* <—White glue

  43. April 22, 2015 at 10:23 AM

    can we use aligator wires

    • April 22, 2015 at 11:57 AM

      Good idea (don’t need the paperclips)

  44. April 30, 2015 at 1:17 AM

    is the cardboard of wood or paper

  45. unname
    May 3, 2015 at 1:09 AM

    Can i use towerpro mg996t digital servo..one more thing can i use 7 segment led common cathode??

  46. shreyas
    May 8, 2015 at 1:22 AM

    sir i am very much interested in your project
    can u pls provide us the ckt diagram
    how it is connected ????

  47. May 23, 2015 at 12:47 PM

    servo motor and display does not work at a same time…….Need help

    • May 23, 2015 at 1:53 PM

      If you are using a 9V battery, may be not enough to power the servo. Use the USB cable or an external power adapter.

      • May 24, 2015 at 1:55 PM

        i have use usb cable but it doesn’t work when servo motor start working the display get turn off and does not show decremented or incremented value……….kindly help me

      • May 26, 2015 at 4:16 PM

        Looks like your servo is a little big or is blocked..

  48. 12234
    May 24, 2015 at 12:30 PM

    Where do I have to connect the aluminium foil?

  49. nik
    June 10, 2015 at 5:41 PM

    Cause when the car is left standing at the entrance down automatically display up to 0

    • June 10, 2015 at 8:16 PM

      Yes Nick, it’s a simple project with a lot of room to improve.

      • khadeijah
        September 14, 2015 at 9:38 AM

        I need some information for this idea , can you help me becouse i will write report about this idea

  50. Sharmae Sardido
    July 1, 2015 at 2:52 AM

    Nice sir… Good job

  51. riya01
    July 9, 2015 at 11:48 AM

    sir please help me for this project. from video i am not getting how you have connecting all the materials. like what’s the use of aluminium foil? I didn’t get that

  52. sajin ahamad
    July 12, 2015 at 2:38 AM

    Sir in diagram, what is the resistor do you use in seven segment display 470 ohm or 470 kilo ohm?

    • chevi
      July 12, 2015 at 2:06 PM

      470 ohms

  53. chevi
    July 12, 2015 at 2:08 PM

    Hi, could you tell me how switch pad works? and… when two aluminium foils come in contact, will arduino receives a pulse or an electric signal?. Thanks for your help,

  54. Joshua Navarro
    July 30, 2015 at 1:01 AM

    good day sir.. may i ask. i can’t understand the lines:

    #define BarLow 177
    #define BarUp 95

    what is the significance of 177 and 95? or why 177 and 95? can we give another values? thank you in advance for your response.

  55. September 13, 2015 at 9:41 AM

    how we can know about components range

  56. khadeijah
    September 14, 2015 at 9:26 AM


  57. khadeijah
    September 14, 2015 at 9:33 AM

    I need some information for this idea , can you help me becouse i will write report about this idea

  58. October 12, 2015 at 2:52 AM

    Hi, Sir. What if we want to use a double seven segment so we can have atleast 99 cars in it. What changes will we make in the program? Thanks. Hoping for your reply.. ASAP.

  59. sukhdeep
    November 5, 2015 at 6:17 PM

    hi sir we are making similar project by using arduino UNO, rfid, servo and lcd 16*2 to display. What code do we need for lcd to display ? Or we just need thid code for servo motor. I am completely new to hardware.

  60. sukhdeep
    November 5, 2015 at 6:19 PM

    sir we are using lcd 16* 2 and rfid along with servo and arduino. we are not using resistors. What code do we need for lcd display ?

  61. Oliver
    November 28, 2015 at 6:18 PM

    Hi great project, just a small question.
    For a GCSE project I’m doing a similar design to yours in that a car enters the no. Of available spaces lowers and when a car exit it rises. I’m also using the arduino however my project will also display and count disabled drivers entering and exiting the car park. I hope to run two arduinos, one for standard drivers and one for disabled both boards will be connected to exit and entrance switches and 7 segment displays. Here’s the question, would it be possible to connect both boards (coded the same) to the same single servo motor.

  62. akshay
    December 11, 2015 at 9:25 PM

    can you send me the schematic of the circuit of breadboard of 7 segment display

  63. Shivam katial
    December 14, 2015 at 1:10 PM

    i am not able to figure out, how u made the switch button using aluminium foil. can u plz help me out sir?

  64. Danijean Tulalian
    January 6, 2016 at 7:12 PM

    Can I ask if what programming language did u used?

  65. Kim
    January 11, 2016 at 9:34 AM

    Can we have your research papers about this.,? Thank you and Godbless

  66. KAMAL
    January 25, 2016 at 5:34 PM

    Please the programm of a parking with the servo motors ( one for tthe in & one for the out) it’s same working like ur programm

    January 26, 2016 at 4:05 AM

    which component is requied for this project ?

  68. souhaila
    January 27, 2016 at 9:06 AM

    im using photoresistor to detect the presence of a car , but i didn’t know how to connect it via the aluminium foil , and i didnt know also where your buttons are in you shema ???

  69. February 4, 2016 at 11:59 AM

    I created the whole project. the numbers work perfect. As i was having problem with Servo overloading the arduino so googled and solved it by attaching an external source with a common ground between the arduino and the servo motor.

    I tried this configuration with a Sweep program and it works perfect.

    But with the parking lot program it keeps rotating till the car hits the circuit whether in or out. When the car hits the circuit it still rotates but at a much lower speed. then after 3 secs it again gains the previous speed.

    The servo never stops. The numbers work perfect but servo is giving me headache…
    I have a feeling the programming might need tweaking
    Please help…..

  1. October 15, 2012 at 1:45 AM
  2. October 15, 2012 at 2:34 PM
  3. October 15, 2012 at 3:14 PM
  4. October 16, 2012 at 12:35 AM
  5. October 17, 2012 at 1:08 AM
  6. January 20, 2013 at 7:08 AM
  7. July 15, 2015 at 2:01 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 40 other followers

%d bloggers like this: