Well I made a test but the led doesnt turn off I tried bridging from pin 3 to gnd or pin to 5v no effect, the serial monitor just keeps printing 1,3. The next thing is how I would get it to stop counting above 2 because printed bottle count also and it was just going up.
int sensorPin = 3;
int relayPin = 13;
int bottleCount = 0;
void setup() {
pinMode(sensorPin, INPUT);
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(digitalRead(sensorPin) == LOW) {
bottleCount++;
}
if(bottleCount == 2); {
digitalWrite(relayPin, HIGH);
Serial.print(relayPin);
}
}