Car counting how to setup 3 cars max

Hi
So i have a car park that has a boom gate entry and boom gate exit.
There are senor pad on entey and senor pad on exit.when car drivers up to boom senor pad open boom like wise on exit.
What i need to do is setup once 3 cars wntry trigger relay that will stay latched till one or more car leave.
So three cars drive in relay latch.fourth car drives up to entry boom no access relay latch holds boom down
One car leaves then count down to two cars allowing one more car in.two cars leave xount to one allow two new cars to entry etc etc please help

If you want to hire someone to write code for you, use the flag button (lower right) to ask the moderator to move the post to the Jobs and Paid Consultancy forum section.

Otherwise, have a look at the "How to get the best out of this forum" post, linked at the head of every forum category.

1 Like

Hi
How do i do that?

Do what?

Link it so more people see it

@austech21 ,

I am a moderator, are you looking to pay someone to do this for you? If so I will move your topic to the appropriate category of the forum.

If you don't want to pay then the helpers here will expect you to put some effort in yourself.

Let me know what you want to do.

Thank you

Hi
I am new to this so learning how arduino works i going to buy one but need to understand how to do car counter

Dive into a beginners Arduino tutorial, get hold of the Arduino project book and learn,

So what i am trying to do is use arduino to do following.
I have a car park that has entry and exit boom gates.
Ground loop senor on entry and exit of gates when car drives up it triggers boom to lift.when car exits drives over ground loop exit boom lifts.
So whatt i nees to do is use arduino and output to trigger a relay so once 3 cars have enter relay triggers latchs.then when car 4,5,6 etc drive up relay stays latch till one or more cars leave.ie 3 cars enter relay latch.4 car drivers up no access when 1 car leaves count drops to 2 so relay delatch allowing boom gate to open letter car in.count now 3.then say 2 cars leave count down to 1 allowing 2 more cars to entry

Is this your classroom assignment?

The forum gets a lot of requests for ready made solutions to homework problems, and parking lot assignments are rather common.

The relay will be the easy part. How are you planning to connect the ground loop sensors to the Arduino?

Does a driver take a ticket as the car enters? Does the driver present a ticket and/or a credit card before exiting? If so, that would accurately count the cars.

No just drivers up to boom gate

I have done it and most others have done it. When the parking gate does not open, back up and cross the sensor again. Then repeat until the gate opens or I get tired and drive off to another parking lot.

Start with basic Arduino sketches.
https://www.arduino.cc/en/Tutorial/BuiltInExamples

Hi
The wires from ground loop go to boom gate then i have two wires from entry boom going to inside office wall same as exit boom

Don't stop there! Continue with the wires. Where do they go to eventually connect to your Arduino?

Hi @austech21
as I have some time right now I wrote a little sketch which may fit your reuirements for the Car Park:

  • 3 parking lots to occupy
  • let a new car in after one leaves out

on my test platform I am using a NANO processor two digital switches which simulate the car sensors on entry and exit and one LED which simulates the barrier. LED on = barrier up and LED off = barrier down.
Now all related to OLED is just to show results on a display. You can replace this with a serial print on the PC- serial terminal.
Check it out and adapt it to your real needs. At least you have something to start with and without any cost :wink:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define entry_switch 3 // Arduino NANO input
#define exit_switch 4 //  Arduino NANO input
#define barrier 2     //  Arduino NANO output
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int num_cars = 0; // number of cars inside the parking
bool in_flag;     // flag for FlipFlop
bool out_flag;    // flag for FlipFlop



void setup() 
{ 
 pinMode(entry_switch, INPUT);
 pinMode(exit_switch, INPUT);
 pinMode(barrier, OUTPUT);
 digitalWrite(barrier,LOW); //initial close barrier 

 // INIT OLED DISPLAY 
 oled.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
 oled.clearDisplay();
 oled.setTextSize(1);
 oled.setTextColor(SSD1306_WHITE);
 oled.setCursor(0,0);
 oled.println("Galactico Car Park");
 oled.println("24 hours parking");
 oled.display();
 // OLED DISPLAY WORKING
 
 delay(2000); //show initial message on OLED for 2 seconds
}

void loop() {
 if(num_cars < 3) 
 {
  if(digitalRead(entry_switch) && !in_flag) 
  {
    in_flag = true;
    digitalWrite(barrier, HIGH);
    num_cars ++; 
  }
 } 
  if(!digitalRead(entry_switch) && in_flag) 
  {
    in_flag = false;
    delay(5000); //wait 5 seconds to close barrier or put some other criterium
    digitalWrite(barrier, LOW); 
  }
 
 if(num_cars > 0) 
 {  
  if(digitalRead(exit_switch) && out_flag) 
  {
   out_flag = false;
   num_cars --;
  }
  if(!digitalRead(exit_switch) && !out_flag) 
  {
     out_flag = true;
  } 
 }
   oled.clearDisplay();
   oled.setCursor(0,0);
   oled.print("Cars parked inside: ");
   oled.println(num_cars);
   oled.display();
}

actually, I am not a C++ expert and I know how hard it can be to get in this stuff having fun from the very beginning

1 Like

if there is a second barrier on the exit you may add it to the sketch, would be your first exercise :wink:

@austech21 if you like to see my HW-testplatform for this project, here it is:


I suppose this is the way to show your problem on this forum in order to get help from the real experts.