however, i wish i could make something like this where you don't include the data of sensor A when the sensor B was incremented, like this

Hard to see in that tiny picture, but writing out the changed value in column 1 or column 2 or both is trivial. If one or more values change, you need to write a record. For each column, determine what to put in that column - a new value or a series of spaces. Then, write the record.

Hard to see in that tiny picture, but writing out the changed value in column 1 or column 2 or both is trivial. If one or more values change, you need to write a record. For each column, determine what to put in that column - a new value or a series of spaces. Then, write the record.

I modified my post. I wish i can create a logger like the one on the second picture. Can you suggest what can i do? thanks!!

if (beeCounterA != lastBeeCounterA) It's hard to tell whether you have a similar prevBeeCounterB, or not. You would need one.

The variable names used in this application are terrible. I look at a name like buttonBeeCounterA and I think of a pin that a switch is connected to. I can't imagine why writing a pin number to the output file is of any interest.

I think that the best thing, at this point, is for you to post all of your code.

// Variables will change:int CurrentNumberofBeesA = 0; // counter for the number of button pressesint ActualStateofCounterA = 0; // state of the button (Either HIGH or LOW)int PreviousStateofCounterA = 0; // previous state of the button (Either HIGH or LOW)int CurrentNumberofBeesB = 0; // counter for the number of button pressesint ActualStateofCounterB = 0; // state of the button (Either HIGH or LOW)int PreviousStateofCounterB= 0; // previous state of the button (Either HIGH or LOW)

long lastEvent= 0; // The last time a bee has entered the feeding stationlong interval= 300; // The debounce time

// compare the buttonState to its previous state if ((ActualStateofCounterA != PreviousStateofCounterA ) || (ActualStateofCounterB != PreviousStateofCounterB)) { // if the state has changed, increment the counter if (ActualStateofCounterA == HIGH && millis() - lastEvent > interval)// Ignore this reading if it is too close to the last one { lastEvent= millis(); // a bee can be recorded) // if the current state is HIGH then the button // wend from off to on:

CurrentNumberofBeesA++; Serial.println("Bees are being detected entering Feeding Station A"); Serial.print("number of bees that entered Feeding Station A: "); Serial.println(CurrentNumberofBeesA);

} { // if the state has changed, increment the counter if (ActualStateofCounterB == HIGH && millis() - lastEvent > interval)// Ignore this reading if it is too close to the last one { lastEvent= millis(); // a bee can be recorded) // if the current state is HIGH then the button // wend from off to on: } CurrentNumberofBeesB++; Serial.println("Bees are being detected entering Feeding Station B"); Serial.print("number of bees that entered Feeding Station B: "); Serial.println(CurrentNumberofBeesB); }

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.

int CurrentNumberofBeesA = 0; // counter for the number of button pressesJust 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.

long lastEvent= 0; // The last time a bee has entered the feeding stationLast 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.

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

// Variables will change:int CurrentNumberofBeesA = 0; // counter for the number of bees that entered the sensorint 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 sensorint 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