Wednesday, June 11, 2014

Arduino Sensor for Solution Volume

Designed for measuring volume of a cylinder as the volume changes. Designed to replace Vernier drop counter for titration or anything.
const int pingPin = 7;
int  r = 25 
void setup() {   Serial.begin(9600);   lcd.begin(16, 2); } void loop() {   long duration, cm;     pinMode(pingPin, OUTPUT);   digitalWrite(pingPin, LOW);   delayMicroseconds(2);   digitalWrite(pingPin, HIGH);   delayMicroseconds(5);   digitalWrite(pingPin, LOW);   pinMode(9, INPUT);   duration = pulseIn(9, HIGH);   cm = microsecondsToCentimeters(duration);
  cm=cm*3.14159265359*r*r;
     Serial.print(cm);   Serial.print("cm");   lcd.setCursor(0, 1);   lcd.print(cm);   Serial.println();      delay(100); } long microsecondsToCentimeters(long microseconds) {   return microseconds / 29 / 2; }

No comments:

Post a Comment