Smart Bus Model: A DIY Robotics Project with Passenger Limit, Auto Ticket Dispenser & Driver Sleep Alert
The Smart Bus Model: a mini bus that counts riders, hands out tickets, and watches the driver
A model bus that manages itself. Sensors at the door count every passenger in and out and physically block the entrance once the bus is full. Each rider who boards gets an automatic paper ticket. And a sensor near the driver's seat sounds an alarm the moment it senses the driver's eyes have stayed closed too long.
What you're building
A model bus that teaches counting logic, automatic dispensing, and safety alerts in one build.
The Smart Bus Model sits on a small platform with a door cut into one side. A pair of sensors watches that doorway and keeps a running count of passengers as they step in and out. The moment the bus reaches its seat limit, a small gate swings shut to physically block anyone else from boarding. Every passenger who boards while there's room gets a small paper ticket pushed out automatically. And near the driver's seat, a sensor keeps watch for closed eyes — if they stay shut too long, a buzzer and flashing light snap the driver back to attention.
Passenger Limit
Two door sensors count riders in and out, and a gate blocks entry the instant the bus is full.
Auto Ticket Dispenser
A small servo pushes out a paper ticket automatically each time a passenger boards.
Driver Sleep Alert
A sensor watches the driver's eyes and sounds an alarm if they close for too long.
Materials list
Most electronics can be reused from a beginner Arduino sensor kit.
Electronics
- 1x Arduino Uno
- 2x IR beam-break sensor modules (entry & exit)
- 1x IR eye-blink / drowsiness sensor module
- 2x micro servo motors (entry gate & ticket dispenser)
- 1x 16x2 LCD display with I2C backpack
- 1x small buzzer
- 3x LEDs (green, red, blue) + 220-ohm resistors
- Jumper wires + breadboard
Bus model & build supplies
- Cardboard or foam board (for the bus body)
- Small paper strips (pre-cut, act as tickets)
- A tiny paper-doll "driver" figure
- Hot glue gun
- Craft knife (adult use only)
- Paint or colored paper for the bus exterior
Wiring reference table
| Component | Component Pin | Arduino Pin |
|---|---|---|
| Entry IR Sensor | Signal | D2 |
| Exit IR Sensor | Signal | D3 |
| Eye / Drowsiness Sensor | Signal | D4 |
| Green LED (Seats OK) | Anode | D5 |
| Red LED (Bus Full) | Anode | D6 |
| Blue LED (Driver Alert) | Anode | D7 |
| Gate Servo | Signal | D9 |
| Ticket Dispenser Servo | Signal | D10 |
| Buzzer | Signal | D11 |
| 16x2 LCD (I2C) | SDA / SCL | A4 / A5 |
| All components | GND | Common GND rail |
Step-by-step build instructions
Work through these in order — test each sensor on the bench before mounting anything on the bus model.
-
Build the bus body and doorway
Cut a bus shape from cardboard or foam board with a clear doorway opening wide enough for a finger or small figure to pass through, since that's how you'll "board" passengers during testing.
-
Mount the entry and exit sensors
Fix the two IR beam-break sensors on either side of the doorway, facing each other, and connect them to D2 (entry) and D3 (exit).
-
Attach the gate servo
Mount a servo beside the doorway with a small arm or bar attached, positioned so it can swing across the opening to block it, wired to D9.
-
Build the ticket dispenser
Stack a few small paper strips in a slot near the door, with the second servo positioned to push the top strip partway out when it rotates, wired to D10.
-
Add the driver's eye sensor
Mount the eye-blink sensor near the tiny driver figure's seat, angled toward where its "eyes" would be, and connect it to D4.
-
Wire the LCD, buzzer, and LEDs
Connect the LCD's SDA/SCL to A4/A5, and wire the buzzer and three status LEDs to their pins as shown in the wiring table.
-
Upload the code and set your limit
Upload the sketch below, then adjust MAX_PASSENGERS to match how many "riders" you want your model bus to hold.
-
Test all three systems
Walk a finger through the entry sensor a few times to confirm counting and ticket dispensing work, fill the bus to test the gate closing, then cover the eye sensor for a few seconds to confirm the driver alert triggers.
Arduino code
Copy this into a new sketch in the Arduino IDE. Install the Servo and LiquidCrystal_I2C libraries first from the Library Manager.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
// ---- Pin setup ----
#define ENTRY_SENSOR_PIN 2
#define EXIT_SENSOR_PIN 3
#define EYE_SENSOR_PIN 4
#define LED_GREEN 5
#define LED_RED 6
#define LED_BLUE 7
#define GATE_SERVO_PIN 9
#define TICKET_SERVO_PIN 10
#define BUZZER_PIN 11
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo gateServo;
Servo ticketServo;
const int MAX_PASSENGERS = 4;
int passengerCount = 0;
unsigned long eyesClosedSince = 0;
const unsigned long DROWSY_LIMIT_MS = 3000; // 3 seconds of closed eyes triggers alarm
bool driverAlertActive = false;
void setup() {
pinMode(ENTRY_SENSOR_PIN, INPUT);
pinMode(EXIT_SENSOR_PIN, INPUT);
pinMode(EYE_SENSOR_PIN, INPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
gateServo.attach(GATE_SERVO_PIN);
ticketServo.attach(TICKET_SERVO_PIN);
gateServo.write(0); // gate open
ticketServo.write(0); // ticket servo resting
lcd.init();
lcd.backlight();
}
void loop() {
handleEntryAndExit();
checkDriverAlert();
updateDisplay();
}
void handleEntryAndExit() {
// Entry sensor: LOW means the beam is broken (someone is passing through)
if (digitalRead(ENTRY_SENSOR_PIN) == LOW) {
if (passengerCount < MAX_PASSENGERS) {
passengerCount++;
dispenseTicket();
} else {
denyEntry();
}
delay(500); // simple debounce so one crossing isn't counted twice
}
if (digitalRead(EXIT_SENSOR_PIN) == LOW) {
if (passengerCount > 0) {
passengerCount--;
}
delay(500);
}
if (passengerCount >= MAX_PASSENGERS) {
gateServo.write(90); // close the gate
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, LOW);
} else {
gateServo.write(0); // keep the gate open
digitalWrite(LED_RED, LOW);
digitalWrite(LED_GREEN, HIGH);
}
}
void dispenseTicket() {
ticketServo.write(90); // push ticket out
delay(400);
ticketServo.write(0); // return to rest
tone(BUZZER_PIN, 1500, 100);
}
void denyEntry() {
tone(BUZZER_PIN, 400, 300);
}
void checkDriverAlert() {
bool eyesClosed = digitalRead(EYE_SENSOR_PIN) == LOW; // LOW = eyes closed on most modules
if (eyesClosed) {
if (eyesClosedSince == 0) {
eyesClosedSince = millis();
} else if (millis() - eyesClosedSince > DROWSY_LIMIT_MS) {
driverAlertActive = true;
}
} else {
eyesClosedSince = 0;
driverAlertActive = false;
}
if (driverAlertActive) {
digitalWrite(LED_BLUE, (millis() / 250) % 2); // blink
tone(BUZZER_PIN, 1000);
} else {
digitalWrite(LED_BLUE, LOW);
noTone(BUZZER_PIN);
}
}
void updateDisplay() {
lcd.setCursor(0, 0);
lcd.print("Bus: ");
lcd.print(passengerCount);
lcd.print("/");
lcd.print(MAX_PASSENGERS);
lcd.print(" ");
lcd.setCursor(0, 1);
if (driverAlertActive) {
lcd.print("WAKE UP DRIVER! ");
} else if (passengerCount >= MAX_PASSENGERS) {
lcd.print("BUS FULL ");
} else {
lcd.print("Seats available ");
}
}
Beginner tip
If the entry sensor counts two passengers for one crossing, increase the debounce delay in handleEntryAndExit() from 500 to around 800 milliseconds.
Safety notes for young makers
Ask an adult to help with wiring and soldering. Keep the buzzer volume reasonable so the alert is noticeable but not startling, and make sure the gate servo's arm has no sharp edges since it moves automatically. This model is for learning and demonstration — it isn't a substitute for real bus safety systems.
Why this project works so well for learning
The Smart Bus Model brings together three ideas that show up across real-world robotics and automation. Counting people in and out with two sensors teaches state tracking — keeping a running number in code that changes based on events. Triggering a servo automatically each time someone boards introduces cause-and-effect automation instead of a simple button press. And timing how long the driver's eyes stay closed before sounding an alarm is a gentle first look at how real driver-monitoring systems work in modern vehicles.
Frequently asked questions
What age group is this robotics project best suited for?
Ages 10 and up can build this with an adult helping on sensor mounting and wiring. Ages 13+ with some Arduino experience can usually manage most of it independently.
Do I need real IR beam-break sensors, or can I use something else?
IR beam-break sensor pairs work best since they detect a clean crossing, but a single IR obstacle sensor per side can work too, with a bit more debounce tuning in the code.
Can I build this without the driver sleep alert system?
Yes. Skip the eye sensor wiring and the checkDriverAlert() function, and you'll still have a fully working passenger counter with automatic ticket dispensing.
How does the eye sensor tell if the driver is asleep?
The sensor bounces infrared light off the eye area and reads whether it's reflecting normally (eyes open) or not (eyes closed). The code only raises an alarm if that closed state lasts longer than a few seconds, so normal blinking doesn't set it off.
Can I change how many passengers the bus allows?
Yes, just change the MAX_PASSENGERS value near the top of the code to any number that fits your model.

Comments
Post a Comment