Titration Automation Day 2: Code

Today, our goal was to explain what the code actually does (because we didn’t write it we are supposed to at least understand it). I’ve commented the code on every line, as you can see here:


If you click on the photo it will take you to flickr where you can zoom in. We also had to modify our code to:

  • Drop 20 drops of water when it is turned on
  • deliver a certain amount (in grams) of water, taking into account the 20 drips of water.

I achieved this by performing test to see how much time it takes to dispense a gram (about 175 ms) and how many grams the 20 drops adds (2.33 grams). Then you just type in how many grams you want, and then when you press the “stream” button it does some math and then dispenses the correct amount. Here’s the code that does that part:

during the setup:

int grams = 95; // enter how many grams you want to dispense

grams = grams – 2.333333; // subtracts what was dripped already at the beginning

and then when you press the button:

timeInterval = 175 * grams;

It’s quite simple, but it works really well. It gets within 1 gram of the target amount when we tested from 60 grams all the way to 100. We will be doing more testing next class, and also see exactly how close it can get by using a more precise balance.


Leave a Reply

Your email address will not be published. Required fields are marked *