Vernier Software and Technology
Vernier Software & Technology
Arduino and Vernier Sensors

Drop Counter

The Vernier Drop Counter records the number of drops that fall from a reagent reservoir. It is often used to perform accurate, automatic titrations. The Drop Counter produces a signal that can be detected on the Arduino digital lines.

The Drop Counter should be connected to the Digital 1 port on the Vernier Arduino Interface Shield or a Digital Protoboard Adapter wired to Arduino pins 2, 3, 4, and 5 as explained in the Connecting Vernier Sensors to the Arduino Using a Breadboard section. The VernierLib library does not support the Drop Counter, but the sample sketch, VernierTutorialDropCount, monitors the sensor and counts drop events over a period of ten seconds. It then reports the number of drops on the Serial Monitor. Note the VernierTutorialDropCount sketch can also be used with a Vernier Photogate to count the number of times the photogate beam is blocked during a period of time.

/* VernierTutorialDropCount (v2017)
 * This sketch counts the number of drops that fall through 
 * a Vernier Drop Counter or Photogate during a 10 second
 * time period.
 * 
 * Plug the Drop Counter or Photogate into the Digital 1 port 
 * on the Vernier Arduino Interface Shield or into a Digital 
 * Protoboard Adapter wired to Arduino pins 2, 3, 4, and 5.
 */

int sensorPin = 2; //create global variable for pin assignment to sensor
unsigned long timeStart; //create global variable for start time

void setup() {
  Serial.begin(9600); //setup communication to display
}

void loop () {
  int dropCount = 0; //initialize local variable for number of drops
  
  timeStart = millis(); //set start time to current time
  while ((millis()-timeStart) <= 10000) //do while current time minus start time is less than 10 seconds
  {
    if (digitalRead(sensorPin)==LOW) //check if drop is blocking sensor
    { 
      dropCount ++; //increment number of drops
      while(digitalRead(sensorPin)==LOW); //pause until drop passes through, then continue
     }
  }
Serial.println(dropCount); //print total number of drops 
}


Contents

Introduction

Vernier Engineering Contest

Vernier recognizes instructors for creative uses of Vernier sensors to introduce engineering concepts and/or practices. Vernier Engineering Award »

Go to top