Sorry for the late post, i was out for a week, anyway i changed some bracket on my code. The one in the BeeCounterA, what happens is that i was able to see the number of count in A but it cannot be log in the sd. When the BeeCounterB counts, it will log its present value and at the SAME time log the present value of counterA. I tried rearranging my brackets to no avail. I also follow what sir Paul recommended to do.
void loop() {
// read the Sensor input pin:
CurrentSensorStateA = digitalRead(BeeSensorA);
CurrentSensorStateB = digitalRead(BeeSensorB);
// compare the Sensor State to its previous state
if (CurrentSensorStateA != PreviousSensorStateA)
{
// if the state has changed, increment the counter for bees
if (CurrentSensorStateA == 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:
BeeCounterA++;
Serial.println("Bees are being detected entering Feeding Station A");
Serial.print("number of bees that entered Feeding Station A: ");
Serial.println(BeeCounterA);
}
}
if (CurrentSensorStateB != PreviousSensorStateB)
{
// if the state has changed, increment the counter for bees
if (CurrentSensorStateB == 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:
BeeCounterB++;
Serial.println("Bees are being detected entering Feeding Station B");
Serial.print("number of bees that entered Feeding Station B: ");
Serial.println(BeeCounterB);
}