Go Down

Topic: datalogger for counter sensor with RTC HELP! (Read 3 times) previous topic - next topic

PaulS

Quote
i hope it will be more understandable.

I'm sorry, but in my opinion, you have a ways to go.

Code: [Select]
int ActualStateofCounterA = 0;         // state of the button (Either HIGH or LOW)
Nowhere in this name is there a clue that it is a switch state. Counter is not a switch. Names like currStateA, currStateB, prevStateA, and prevStateB give a much clearer picture.

Code: [Select]
int CurrentNumberofBeesA = 0;   // counter for the number of button presses
Just out of curiosity, how do you get the bees to press the switches? It seems unlikely that they do, so it seems unlikely that you are using pushbutton switches. The names of variables, and the comments should reflect the kind of hardware actually used.

Code: [Select]
long lastEvent= 0; // The last time a bee has entered the feeding station
Last event of what kind? Details are important. Reading the comments is useful, but 300 lines later in the code, I won't remember what kind of event this is supposed to be. lastBeeFeeding or lastEventLogged would tell me, without the need for comments, exactly what last event.

iNgine

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

Code: [Select]
// 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

Go Up