You can build a basic parking-lot counter with two sensors, an Arduino, Processing, and a PHP endpoint: the Arduino updates occupancy when a car enters or exits, Processing reads the count over serial, and PHP receives it for display or storage. The approach is useful as a learning prototype, but sensor placement and direction logic matter more than the web connection: the original project publishes no validated accuracy figure.
How the Arduino–Processing–PHP car counter works
The design separates the job into three stages. A sensor at the entrance signals an incoming vehicle; a second sensor at the exit signals an outgoing one. The Arduino adjusts the occupancy count, sends it as a serial line to a computer running Processing, and Processing sends the value to a PHP endpoint. The endpoint can run on the same computer or on a hosted HTTPS server. Hackster’s project presents this as a simple way to count cars entering and leaving a parking lot.
In this design, the Arduino tracks occupancy rather than merely logging vehicle passages: an entry adds one and an exit subtracts one. Keep the count at zero or above if it represents cars currently in the lot. If you need traffic totals instead, record entry and exit events separately rather than treating a single changing number as a historical count.
Parts and software for the original project
- Arduino UNO
- Two generic PIR motion sensors, one positioned for entry and one for exit
- LED and jumper wires
- A computer running Processing, connected to the Arduino over USB serial
- A PHP endpoint, hosted locally or on a server
Arduino’s serial tutorial demonstrates the general pattern of sending Arduino serial data to Processing using a serial library, with an UNO R3 and an ultrasonic sensor in its example: Arduino’s Processing tutorial. The sensor in that tutorial is not a replacement for the two PIR sensors specified by the car-counter project.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
- TURN CODE INTO REAL-WORLD RESULTS — Follow 22+ guided lessons to make LEDs blink, read temperature and distance, move servo and stepper motors, control an LCD and respond to joystick or IR input; ideal for a family weekend build, homeschool unit, coding club or STEM classroom
- MORE PROJECT VARIETY IN ONE ORGANIZED KIT — Includes the UNO R3 controller, LCD1602 with pre-soldered header, breadboard power module, ultrasonic and DHT11 sensors, joystick, IR receiver and remote, SG90 servo, stepper motor, relay, DC motor, fan blade, displays, LEDs, buttons, resistors and jumper wires
- START WITHOUT SOLDERING — Plug-in modules, a solderless breadboard and the pre-soldered LCD help beginners focus on wiring, code and testing; the illustrated component list makes it easier to find each part and move from one lesson to the next
- LEARN THE LOGIC, THEN CREATE YOUR OWN — Use Arduino IDE and the included example code to understand digital input and output, analog sensing, timing, motor control and display functions, then change thresholds, speeds and sequences for alarms, environmental monitors, reaction games and motion projects
- CLEAR SETUP SUPPORT FOR FIRST-TIME BUILDERS — Download the latest tutorial and code, select the UNO board and correct computer port, check component polarity and breadboard rows, and keep power-module input at 9V or below; younger learners should work with an experienced adult
Build the data flow
- Position the sensors. Place one sensor to detect vehicles crossing the entry and the other to detect vehicles crossing the exit. Arrange the lanes so that the intended direction is clear.
- Turn sensor signals into single events. Add debouncing or a cooldown and use state transitions so a vehicle holding a sensor active does not increment or decrement repeatedly. Treat ambiguous direction and reversals as cases that need explicit handling.
- Update occupancy on the Arduino. Increment for entry and decrement for exit. Prevent negative values if the number is intended to represent cars currently parked.
- Send a line-oriented value over serial. Have the Arduino send the count in a simple, consistent format, such as one number followed by a newline. This gives Processing a clear boundary for each update.
- Read the serial line in Processing. Use Processing’s serial support to receive and parse each complete line. The Hackster implementation uses Processing’s documented
loadStrings()approach to call the PHP endpoint. - Validate and handle the value in PHP. Check that the incoming value is numeric and within an expected range before storing it or forwarding it to a display. Protect the endpoint with authentication and HTTPS if it is reachable over a network.
- Choose what to display or retain. A current-availability display needs the latest occupancy value. Historical reporting also requires saving events or counts with timestamps.
Where this approach is reliable—and where it can miscount
A sensor activation is not automatically proof that exactly one car crossed in the intended direction. The Arduino Forum cautions that simultaneous entry and exit, tailgating, people crossing optical sensors, reversing, and unclear lane direction can all lead to false counts. The forum discussion on parking-lot counting recommends planning for those edge cases rather than assuming one sensor trigger always equals one vehicle.
- Simultaneous entry and exit: Separate entry and exit sensors help distinguish the two events, but simultaneous signals still need defined logic.
- Tailgating: Two close vehicles may be detected as one continuous activation. Sensor spacing, state-transition logic, and testing with realistic traffic can reduce the risk, but do not establish a guaranteed accuracy rate.
- Reversing or uncertain direction: A single detection may not reveal whether a car entered or left. A one-way lane or explicit direction sensing is preferable when direction matters.
- Unintended movement: People or other motion near a sensor can create an event. Mounting and alignment should minimize crossings unrelated to vehicles.
- Count drift: Missed or extra events accumulate. Reconcile the displayed occupancy periodically, for example when the lot is empty.
The original project does not publish a controlled accuracy result, so there is no supported percentage to use when judging whether it is suitable for a live facility. Treat it as a prototype unless it has been tested under the actual lane layout, lighting, weather, traffic patterns, and operating conditions.
Rank #2
- 30+ Guided Electronics Projects: Start with LEDs and build toward LCD1602 displays, RFID access, motion detection, distance sensing, motor control and environmental monitoring for STEM learning, coding clubs, classrooms and hobby projects
- 200+ Components Across 63 Types: Includes an ELEGOO UNO R3 controller, LCD1602, RC522 RFID, RTC, HC-SR501 PIR sensor, ultrasonic sensor, DHT11, GY-521, MAX7219, keypad, joystick, relay, SG90 servo, stepper motor, breadboard and more
- Begin Without Soldering: Pre-soldered modules, a solderless breadboard, organized storage case and small-parts box reduce setup time and help beginners move from lesson to lesson while keeping LEDs, ICs, wires and sensors easy to find
- Learn, Modify and Create: Program the ELEGOO UNO R3 board with Arduino IDE using the included PDF tutorial and example code, then adjust sensor thresholds, timing, display text and motor behavior to turn guided lessons into original projects
- Flexible Power and Project Setup: Includes a 9 V, 1 A power supply, breadboard power module, 9 V battery and USB cable to support controller, breadboard and module experiments without sourcing basic setup accessories separately
Choose a sensing design for the site
PIR sensors are the specified parts in the simple project, but sensing method should follow the installation rather than convenience alone. A current SunFounder example uses two ultrasonic modules with an Arduino UNO R4 Minima or WiFi, servo, I2C LCD 1602, breadboard, wires, and USB-C cable to detect vehicles and update a parking count: SunFounder’s parking-lot example. It demonstrates another build pattern, not a validated head-to-head performance comparison.
| Design | What it detects | Useful distinction | Trade-off to consider |
|---|---|---|---|
| Two PIR sensors | Motion near separate entry and exit points | Simple arrangement for a clearly separated, one-way entry and exit | Motion alone may not establish vehicle direction or distinguish closely spaced traffic. |
| Ultrasonic modules | Distance changes near the sensor | Can be used in a vehicle-detection layout such as SunFounder’s example | Placement and detection logic must suit the lane; the cited example does not establish comparative accuracy. |
| Beam-break sensors | An interruption of a beam across a path | A defined crossing point can make a passage event clearer | A single beam interruption does not necessarily determine travel direction or separate tailgating vehicles. |
| Pressure tube | Pressure from a vehicle passing over a tube | Can record traffic events and timestamps without relying on a desktop serial bridge | It counts passage events; occupancy still requires direction and entry/exit logic. |
The alternatives in this table describe sensing principles, not measured winners. Consider direction discrimination, false triggers from people or surroundings, tailgating, power needs, and whether the goal is lot occupancy or just traffic-event logging.
Rank #3
- The most economical kit comes with everything compatible with Arduino to starting programming for beginners .
- This is the upgraded starter kits come with a 9V 1A Power Adapter (At least $5.99 on amazon) to replace a 9V Battery , and the Lcd1602 module come with pin header(not need to be soldered by yourself).
- Include High Quality Base Board base on Arduino UNO R3 compatible with Arduino IED and Sensors, Servo, Motor, ULN2003 driver board, lcds, etc.
- Free PDF Tutorial and Datasheet are available to download from our official website or you can contact our customer service.
- All of the Components and Integrated Circuits are individually packaged and labeled, and packing in a plastic box which is bigger enough for you.
When to use a standalone road-tube counter instead
Arduino Project Hub’s road-tube counter uses a pressure sensor to detect a vehicle passing over a tube, applies a moving-average filter to identify spikes, timestamps events with an RTC, and writes readings to an SD card. Its Arduino can sleep during inactive hours. This design is a better fit when the goal is standalone traffic logging rather than a live, network-fed parking occupancy display; passage data alone does not tell you how many cars remain in a lot.
Quick Recap
Best Value
- All-in-One Starter Kit for Beginners: Part of the Powered by Arduino program, this kit includes an original Arduino UNO R4 WiFi, 300+ high-quality components, 50+ hands-on projects (30 basic, 13 fun, and 8 IoT), and 100+ free video lessons co-created with renowned educator Paul McWhorter. Designed for beginners ages 8+, it provides a complete, step-by-step path to learn Arduino, electronics, coding, and IoT. RoHS compliant for added safety and quality, it also makes a thoughtful gift for tech enthusiasts, students, and aspiring makers for birthdays, holidays, and special occasions
- Powerful Arduino Uno R4 WiFi Board: Upgraded from the Arduino Uno R3, the Arduino Uno R4 WiFi features a 32-bit processor, more memory, and built-in WiFi and Bluetooth, enabling connection to third-party apps for more interactive and practical projects.
- 300+ Components for Endless Possibilities: With 300+ components and sensors, this kit is perfect for portable projects. It features step-by-step tutorials, open-source code, and compatibility with other Arduino boards like Uno R3 and Nano, offering endless customization and learning opportunities.
- Engaging Projects for Every Skill Level: Featuring 50 projects (30 basic, 13 fun, 8 IoT) with IoT app integration like Arduino IoT Cloud , this kit supports Arduino C++ programming, making it perfect for students, teachers, and engineers to learn, code, and create at any skill level.
- Dedicated Support for Beginners: Alongside online resources and video tutorials, SunFounder provides technical support and troubleshooting forums to help beginners solve programming challenges with ease.
Rank #4
- LEARN ELECTRONICS AND CODING FROM SCRATCH: Start your maker journey or enhance classroom learning with the Arduino Starter Kit R4 – no prior experience required. Includes a printed project book and all components for 13 hands-on tutorials, as well as access to a growing repository of projects that will be added over time.
- POWERED BY THE ARDUINO UNO R4 WIFI BOARD: Discover modern connectivity and performance with the Arduino UNO R4 WiFi, featuring built-in Wi-Fi and Bluetooth and full compatibility with the Arduino ecosystem.
- CERTIFICATION VOUCHER INCLUDED: Once you’ve mastered sensors, motors, displays, and logic through the projects, take the official Arduino Fundamentals certification exam with the voucher that comes with your kit.
- BONUS DIGITAL RESOURCES: Register your kit online to unlock extra projects, multilingual lessons (Italian, German, French), and exclusive online content designed by the Arduino team.
- DESIGNED FOR LEARNING AND TEACHING: Ideal for classrooms, labs, or self-learners. Combine hands-on experiments with clear explanations and an AI coding assistant to support you as you grow.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

