datalogger for counter sensor with RTC HELP!

Pardon me, okay what i did here is that i have a pulse sensor, It is a phototransistor and an IR led, when the bee passed that a pulse (HIGH) will be detected, and it must increment the number. I originally modified the StateChangedetection program for this, and as a preliminary test i used push buttons to replace the sensor for conveniency purposes

BTW i replaced it this way

// Variables will change:
int CurrentNumberofBeesA = 0;   // counter for the number of bees that entered the sensor
int ActualStateofSensorA = 0;         // state of the sensor (Either HIGH or LOW)
int PreviousStateofSensorA = 0;     // previous state of the sensor (Either HIGH or LOW)
int CurrentNumberofBeesB = 0;   // counter for the number of bees that entered the sensor
int ActualStateofSensorB = 0;         // state of the sensor (Either HIGH or LOW)
int PreviousStateofSensorB= 0;     // previous state of the sensor (Either HIGH or LOW)


long lastEvent= 0; // The last time a bee has entered the feeding station or the last time a bee was detected by the sensor