Did I drink enough water today?

Using light and force sensors

Made by Cheng (Vanessa) Li

Created: January 28th, 2015

0

Scenario & Purpose

To keep track of how much water I consumed during the day, I designed the prototype that employs a force sensor and a light sensor. It will track only when I drink a certain amount of water during the daytime, which means the force reading and light reading need to be high enough to trigger the tracking system. The amount of water is measured by the frsReading; day or night is judged by photoCellReading. The variable drink indicates whether I just put a glass of water on the force sensor during the day.


0
int ledPin = D0;
int ledBrightness = 0;

int frsPin = A0;
int frsReading = 0;

int photoCellPin = A1;
int photoCellReading = 0;

int drink = 0;

void setup() {
  pinMode(ledPin, OUTPUT);
  Spark.variable("force", &frsReading, INT);
  Spark.variable("light", &photoCellReading, INT);
  Spark.variable("drink", &drink, INT);
}

void loop() {
  // Read from the frsPin, and use the reading to control brightness of the LED
  frsReading = analogRead(frsPin);
  ledBrightness = map(frsReading, 0, 4095, 0, 255);
  analogWrite(ledPin, ledBrightness);
  // Read from the photoCellReading
  photoCellReading = analogRead(photoCellPin);
  delay(100);
  // frsReading > 1000 means you have enough water; photoCellReading > 1000 means it's in the daytime
  if (frsReading > 1000 && photoCellReading > 1000) {
    drink = 1;
  } else {
    drink = 0;
  }
}
Click to Expand
0

To connect Spark with my Twitter account, I'm using IFTTT to monitor the drink variable and let it tweet when drink turns from 0 to 1.

0

The following shows the detailed settings of IFTTT.

0

Voila!

Here is how it looks like when IFTTT automatically tweets for me.

x