Digital Measuring Cup

timothykc's picture

 

Description
 
Too lazy to use more than one measuring cup? Unable to read the markings on a measuring cup? Think it's more practical to hook a computer up and pour liquids nearby?  If you answered yes to all of the above, I've got a useless device for you!
 
The digitial measuring cup. Pour water into it, and the visual display will show you how much has been filled.
 
Disclaimer: It's not finely calibrated, at all wink
 
Materials:
- Analog input device (Force Sensitive Resistor)
- A Measure Cup
- Museum Gel to increase contact between cup and resistor
 
 
/* Ardunio Code to get input from analog sensors */
 
const int input1 = A0;      // sensor to control red color
const int input2 = A1;    // sensor to control green color
const int input3 = A2;     // sensor to control blue color
 
void setup()
{
  Serial.begin(9600);
}
 
void loop()
{
  Serial.print(analogRead(input1));
  Serial.print(",");
  Serial.print(analogRead(input2));
  Serial.print(",");
  Serial.println(analogRead(input3));
}
 
 
/*  Tim's Code to make Analog 1 data translate into a visual display
 
Adapted from:
http://www.arduino.cc/en/Tutorial/VirtualColorMixer
 created 2 Dec 2006
 by David A. Mellis
 modified 4 Sep 2010
//  by Tom Igoe and Scott Fitzgerald
 
 
*/ 
 
 import processing.serial.*;
 
 float analogInput = 0;        // From Analog
 Serial myPort;
 
 void setup() {
 size(300, 300);
 noStroke();
  fill (40,40,40);
 
 ellipse(150,150,299,299);
 
 // List all the available serial ports
 println(Serial.list());
 // I know that the first port in the serial list on my mac
 // is always my  Arduino, so I open Serial.list()[0].
 // Open whatever port is the one you're using.
 myPort = new Serial(this, Serial.list()[0], 9600);
 // don't generate a serialEvent() unless you get a newline character:
 myPort.bufferUntil('\n');
 }
 
 void draw() {
 // set the background color with the color values:  
 
 fill (40,40,40);
 ellipse(150,150,299,299);
 
 
 fill (204,100,40);
 arc(150, 150, 299, 299, PI/2, analogInput);
 
 }
 
 void serialEvent(Serial myPort) { 
 // get the ASCII string:
 String inString = myPort.readStringUntil('\n');
 
 if (inString != null) {
 // trim off any whitespace:
 inString = trim(inString);
 // split the string on the commas and convert the 
 // resulting substrings into an integer array:
 int [] fraction = int (split(inString, ","));
 // if the array has at least three elements, you know
 // you got the whole thing.  Put the numbers in the
 // color variables:
 if (fraction.length >=3) {
 // map them to the range 0-255:
 analogInput = map(fraction[0], 0, 1023, 0, 2.5*PI);
 }
 }
 }
photo 2.JPG
photo 1.JPG
0
Your rating: None