Passager counter for a bus

Hi everyone;

I just design a circuit and a program using an LCD display to count the passager going in or out for a school bus. I been driving a school bus - I have a ABZ licence <- A : Tractor Trailer & 72 pass School Bus & Air Brake Endorsment ( 20 pass - most of the time & 72 pass recently - summer run ) for the past 8 years. ( I know I am not working in electronics - I was in the mid 90's but was layoff and unlucky to find employment in my old field ). The raison I am building a counter system, is because I am doing Tennis Canada - Rogers Cup to drive peoples from parking lot to the Rexale Center ( located at York University in Toronto ) and the client request to count the number of people going in/out of the bus.

The system included : a photo-transistor sensor to count passager - light source is a LEDs Flash Light, a trip reset switch and a stop counting switch. I operate that way : I am full or at the last stop, a trip number will show ( ## <=48 ) The number 48 is the max adult can fit inside a school bus, I select a stop counting, when I arrive, I reset the trip and select counting mode.

My system work , BUT the opto sensor is "so-so" ( Too sensive, not sensitive, can not make it mind ) It look like I will re-design using op-amp has a comparator.

Here the code, sensor schematics and a picture. Let me know of what you guys thinks.

/*
size = 3604

To count the number of passagers going into a School Bus.

Display the number of passager per trip and indicated when 
48 is reach - FULL ( max capacity - adult only ) 

Also indicated the total number of passagers that use the bus 

Use :

1 LCD Display - parralel type
1 photo-transistor
1 push-on switch
1 SPST switch
1 10 K pot
1 220 R for display backlight
4 1 K resistors
1 NPN 2N3904
1 4.7 K resistor


Created by Serge J Desjardins aka techone
Toronto, Ontario Canada

*/

#include <LiquidCrystal.h> // Library for LCD

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // LCD interface pin

const byte pinin[2]={6,5,}; // Input pin

boolean pudo; // Pick-up / Drop-off switch 
boolean stz;  // Start to Zero - reset for a new trip

byte roll; // just a count variable
byte trip; // number of passager during the trip 

unsigned int pass; // total of passagers
unsigned int passone; // Use to count the passagers

volatile byte count; // counting the people from the opto sensor

void setup()
  {
  for (roll=0;roll>3;roll++) 
  {
    pinMode (pinin[roll], INPUT); // init the input pins 
  }  
  attachInterrupt (1, passcount, FALLING); // set the opto sensor using interrupt
  
  //Init the LCD display to show the info
  
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print("Trip:");
  lcd.setCursor(0,1);
  lcd.print("Total Pass:");
  
  // Init the variable to zero
  
  pudo=LOW;
  stz=LOW;
  trip=0;
  pass=0;
  passone=0;
  count=0;
  }

void loop()
{
 pudo= digitalRead (pinin[0]); // Read DO/PU switch
 delay (100); 
 if (pudo==HIGH)
 
 // Display the paasager info
 {
   lcd.setCursor(5,0);
   lcd.print(trip,DEC);
   lcd.setCursor(11,1);
   lcd.print(pass,DEC);
  if (trip>=48 ) // indicate when you are at max capacity which is 48 
   {
     lcd.setCursor(8,0);
     lcd.print("Full");
   }   
   trip=count;  // transfer volatile data into trip
   pass=trip+passone;
 }
 else
 {
   count=0; // make sure the count is keep zero 
   stz=digitalRead (pinin[1]); // check for reset data switch
   delay (100);
   if (stz==HIGH) // reset the display to start recounting passager 
   {
     trip=0;
     passone=pass; // updated total passager
     lcd.setCursor (5,0);
     lcd.print(trip,DEC);
     lcd.setCursor (6,0);
     lcd.print("       "); 
   }  
     
 }  
}   
void passcount() // Interrupt subroutine
{
  count++;
}

Techone, what is the source of light for your photosensor?? You need a small beam of light aimed across the door area at waist level, and also some timing to require beam broken for "long enough", like maybe 100 ms, and 'enough' time between people so that arms or packages don't get counted..

So that sunlight doesn't affect it, sometimes a "modulated" Infrared beam is used, with a transmitter unit and receiver unit, like this:
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=86

Regards, Terry King
...In The Woods In Vermont
terry@yourduino.com

Discalimer: Mentioned something from my own shop!

@ terryking228

Techone, what is the source of light for your photosensor?? You need a small beam of light aimed across the door area at waist level, and also some timing to require beam broken for "long enough", like maybe 100 ms, and 'enough' time between people so that arms or packages don't get counted..

I use a LED's Flash Light. It look powerfull. I bought at Canadian Tire for $7.99. I do agree to add delay in the program. I will insert a delay(200); in the interrupt subroutine.

Here a picture of my location the light beam / sensor will be located.

PS: Every time I want to check my post, Explorer ( Win XP ) always "lock-up" ...annoying !! The rest of the posts are fine.