Toilet Vacancy Monitor

Made by Christopher Holliday

This project is designed to communicate whether the bathroom is vacant, and to alert a user as they are leaving if they forgot to put the seat back down. A proximity sensor keeps track of whether or not there is someone in front of the toilet, and a Force Sensitive Resistor (FSR) keeps track of whether or not the toilet seat is down. There are two green LEDs, one of which turns on to indicate that the bathroom is vacant, and the other turns on to indicate that the toilet seat is down. There is a small speaker, which buzzes if the toilet seat is up, and there is no one at the toilet (they left the seat up).

Created: January 27th, 2015

0
// Define the FSR Pin and create a variable to hold the FSR reading.
int fsrPin = A0;
int fsrReading = 0;

// Define the pin for the LED associated with the FSR and the LED 
// associated with the proximity sensor.
int ledPin = D0;
int greenPin = A4;

// Define a variable to store the readings from the proximity sensor.
int x;

// Define the speaker pin.
int soundPin = D1;

// Time for setup.  Set the LED and speaker pins to output.
// Set the proximity sensor pin (A1) to input.
void setup()
{
  pinMode(ledPin, OUTPUT);
  Spark.variable("force", &fsrReading, INT);
  Spark.variable("x", &x, INT);
  pinMode(A1, INPUT);
  pinMode(soundPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

// Time to create the loop.
void loop()
{

// Read the FSR and proximity sensors.
  fsrReading = analogRead(fsrPin);
  delay(100);
  x = analogRead(A1);

// Next is a series of if statements to control the LEDs and speaker.
// I used if statements because I wanted all of the LEDs and 
// the speaker to either be on or off.

// If someone is within range of the proximity sensor, turn off the
// vacancy light and off the speaker.
  if (x>900)
  {
    analogWrite(greenPin, 0);
    analogWrite(soundPin, 0);
  }

// If no one is within range of the proximity sensor, turn on the
// vacancy light.
  if (x<900)
  {
    analogWrite(greenPin,255);
  }

// If the seat is not pressing on the FSR, and no one is within 
// range of the proximity sensor, turn the speaker on.
  if (fsrReading<2000 && x<900)
  {
    analogWrite(soundPin,100);
  }

// If the seat is pressing on the FSR, turn the speaker off and
// the seat is down light on.
  if (fsrReading>2000)
  {
    analogWrite(soundPin, 0);
    analogWrite(ledPin, 255);
  }

// If the seat is not pressing on the FSR, turn the seat is down
// light off.
  if (fsrReading<2000)
  {
    analogWrite(ledPin, 0);
  }

}
Click to Expand
0
x
Share this Project


About

This project is designed to communicate whether the bathroom is vacant, and to alert a user as they are leaving if they forgot to put the seat back down.

A proximity sensor keeps track of whether or not there is someone in front of the toilet, and a Force Sensitive Resistor (FSR) keeps track of whether or not the toilet seat is down.

There are two green LEDs, one of which turns on to indicate that the bathroom is vacant, and the other turns on to indicate that the toilet seat is down.

There is a small speaker, which buzzes if the toilet seat is up, and there is no one at the toilet (they left the seat up).