IOTOILET

Made by Varun Gadh · UNLISTED (SHOWN IN POOLS)

What if we could use connected devices to make the restroom experience less hazardous?

Created: January 25th, 2018

0

Intention

Living in a house with ten people sharing three and a half bathrooms, my friend Hal* is wary of the cleanliness of his restroom. Naturally neat, he worries about the germs and detritus that could be shared. What if we could use connected devices to make Hal’s restroom experience a bit less terrifying?

Using a Particle Photon microcontroller, a breadboard, two or three servo motors, an LED indicator light, either a switch or an FSR, acrylic components, and the blynk@0.5.0 smartphone app library, the IOTOILET mechanism will automatically lift and lower the toilet seat. The system will engage with Hal and other users through a smartphone app as well as through an indicator light. 

0

Process

Fabrication:

Laser cut cardboard was glued to a servo, which is controlled by the particle photon.
A blue LED blinks during the raising & lowering, and a green LED breathes once a comfortable position is reached.

0
The seat rising & falling based on text commands "up" and "down"
0

Parts & Components

Particle Photon
Arduino Uno (for power)

Large Breadboard
Small breadboard

Wires
One RGB LED or one green 3.3V LED and one blue 3.3V LED
Laser-Cut Cardboard Toilet Seat
Three ~500 ohm resistors

One large servo
One small bracket




0
//
    //∆∆∆∆     SERVO STUFF     ∆∆∆∆
    //
    int servoPin = D0;
    Servo myServo;
    int servoPos = 0;
    //Servo theServo;
    //int servo1Pos = 0;
    //int servo2Pos = 0;

    //
    //∆∆∆∆          led STUFF          ∆∆∆∆
    //
    /*
    int bluePin = D3;    // RED pin of the LED to PWM pin **A4**
    int greenPin = D1;  // GREEN pin of the LED to PWM pin **D0**
    //int bluePin = D2;   // BLUE pin of the LED to PWM pin **D1**
    int red = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
    int green = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
    int blue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255</td>
    */


    //
    //∆∆∆∆          PHOTORESISTOR STUFF      ∆∆∆∆
    //
    // Define a pin that we'll place the photo cell on
    // Remember to add a 10K Ohm pull-down resistor too.
    int photoCellPin = A0;

    // Create a variable to hold the light reading
    int photoCellReading = 0;



    void setup() {
      Serial.begin(9600);
      //Serial.begin( 9600 );
      //Serial.print( "Looped " );
      // attaches the servo on the A7 pin to the servo object
      myServo.attach( D0 );

      //Register our Particle to control the servo
      Particle.function("servo", servoControl);

      // Keep a cloud variable for the current position
      Particle.variable("servoPos" , &servoPos , INT );

      //

      // Set up our pins for output

      //pinMode( redPin, OUTPUT);
      /*
      pinMode( greenPin, OUTPUT);
      pinMode( bluePin, OUTPUT);
      */
/*
      // turn them all off...
      analogWrite( redPin, 0);
      analogWrite( greenPin, 0);
      */
      //analogWrite( bluePin, blue);


      }

    void loop() {


      // First... On
      //digitalWrite(bluePin, HIGH);   // Turn ON the LED pins
      //delay(1000);               // Wait for 1000mS = 1 second

      // Now... Off
      //digitalWrite(bluePin, LOW);   // Turn OFF the LED pins
      //delay(1000);
    }

    int servoControl(String command)
    {

      /*

       int upPos = 100;
       int downPos = 10;
        // Convert

       if(command.equals("up"))
       {
         int newPos = upPos();
         Serial.println("going up");
       }
       else if(command.equals("down"))
       {
         int newPos = downPos; //test these
         Serial.println("going down");

       }
       else
       {
         Serial.println("incorrect servo command, taking no action");
         return 1;

       }
       Serial.println(newPos);
       //int newPos = command.toInt();

       // Make sure it is in the right range
       // And set the position
       servoPos = constrain( newPos, 0 , 180);
       //servo2Pos = constrain( newPos, 0 , 180);
       // Set the servo
       myServo.write( servoPos );

       //theServo.write( servo2Pos );
       //
       //WE SHOULD TIME HOW LONG IT TAKES TO TRAVEL, THEN JUST BLINK FOR THAT LONG
       //
       //blinkLED(100, 100, 120);
       //setLED(0,250,0);


       // done
       */

       // Convert
       int upPos = 100;
       int newPos = 90;
       if(command.equals("up"))
       {
         newPos = upPos;
         Serial.println("going up");
         //Serial.print(newPos );
       }
       else if(command.equals("down"))
       {
         newPos = 10; //test these
         Serial.println("going down");

       }
       else{
          newPos = command.toInt();
       }



            // Make sure it is in the right range
      // And set the position
      servoPos = constrain( newPos, 0 , 180);

      // Set the servo
      myServo.write( servoPos );
    //Serial.println("wazzup" );
      Serial.print(newPos );

      //BLINK IT
      //blinkLED(100, 100, 120);

      //blinkLED(230, 230);



       return 1;
    }

    //function for controlling individual LEDs
    int blinkLEDIndividualLEDs(int g, int b)
    {

      //red = r;
      green = g;
      blue = b;
      // write the mixed color
      int delayTime = 1000;
      int totalTime = 10000;
      int numberBlinks = totalTime/delayTime;

      int blank = 0;

      for(int i = 0; i < numberBlinks; i++){
        //analogWrite( redPin, red);
        analogWrite( greenPin, green);
        analogWrite( bluePin, blue);
        delay(delayTime);

        //analogWrite( redPin, blank);
        analogWrite( greenPin, blank);
        analogWrite( bluePin, blank);
        delay(delayTime);
      }

      return 1;
    }

    //function for controlling RGB LED
    int blinkLED(int r, int g, int b)
    {

      red = r;
      green = g;
      blue = b;
      // write the mixed color
      int delayTime = 1000;
      int totalTime = 10000;
      int numberBlinks = totalTime/delayTime;

      int blank = 0;

      for(int i = 0; i < numberBlinks; i++){
        analogWrite( redPin, red);
        analogWrite( greenPin, green);
        analogWrite( bluePin, blue);
        delay(delayTime);

        analogWrite( redPin, blank);
        analogWrite( greenPin, blank);
        analogWrite( bluePin, blank);
        delay(delayTime);
      }

      return 1;
    }

    int setLED(int r, int g, int b)
    {

      red = r;
      green = g;
      blue = b;
      analogWrite( redPin, red);
      analogWrite( greenPin, green);
      analogWrite( bluePin, blue);


      return 1;
    }
Click to Expand
0

^ Code to pull live commands ("up" and "down"), pushes to servo. For some reason (likely a wiring mistake), the LED controls can't work at the same time as the motor, so this version has the LED commands commented out.

0
//
    //∆∆∆∆     SERVO STUFF     ∆∆∆∆
    //
    int servoPin = D0;
    Servo myServo;
    int servoPos = 0;
    //Servo theServo;
    //int servo1Pos = 0;
    //int servo2Pos = 0;

    //
    //∆∆∆∆          led STUFF          ∆∆∆∆
    //

    int bluePin = D3;    // RED pin of the LED to PWM pin **A4**
    int greenPin = D1;  // GREEN pin of the LED to PWM pin **D0**
    //int bluePin = D2;   // BLUE pin of the LED to PWM pin **D1**
    int red = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
    int green = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
    int blue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255</td>



    //
    //∆∆∆∆          PHOTORESISTOR STUFF      ∆∆∆∆
    //
    // Define a pin that we'll place the photo cell on
    // Remember to add a 10K Ohm pull-down resistor too.
    int photoCellPin = A0;

    // Create a variable to hold the light reading
    int photoCellReading = 0;



    void setup() {
      Serial.begin(9600);
      //Serial.begin( 9600 );
      //Serial.print( "Looped " );
      // attaches the servo on the A7 pin to the servo object
      myServo.attach( D0 );

      //Register our Particle to control the servo
      Particle.function("servo", servoControl);

      // Keep a cloud variable for the current position
      Particle.variable("servoPos" , &servoPos , INT );

      //

      // Set up our pins for output

      //pinMode( redPin, OUTPUT);

      pinMode( greenPin, OUTPUT);
      pinMode( bluePin, OUTPUT);

/*
      // turn them all off...
      analogWrite( redPin, 0);
      analogWrite( greenPin, 0);
      */
      //analogWrite( bluePin, blue);


      }

    void loop() {


      // First... On
      //digitalWrite(bluePin, HIGH);   // Turn ON the LED pins
      //delay(1000);               // Wait for 1000mS = 1 second

      // Now... Off
      //digitalWrite(bluePin, LOW);   // Turn OFF the LED pins
      //delay(1000);
    }

    int servoControl(String command)
    {

      /*

       int upPos = 100;
       int downPos = 10;
        // Convert

       if(command.equals("up"))
       {
         int newPos = upPos();
         Serial.println("going up");
       }
       else if(command.equals("down"))
       {
         int newPos = downPos; //test these
         Serial.println("going down");

       }
       else
       {
         Serial.println("incorrect servo command, taking no action");
         return 1;

       }
       Serial.println(newPos);
       //int newPos = command.toInt();

       // Make sure it is in the right range
       // And set the position
       servoPos = constrain( newPos, 0 , 180);
       //servo2Pos = constrain( newPos, 0 , 180);
       // Set the servo
       myServo.write( servoPos );

       //theServo.write( servo2Pos );
       //
       //WE SHOULD TIME HOW LONG IT TAKES TO TRAVEL, THEN JUST BLINK FOR THAT LONG
       //
       //blinkLED(100, 100, 120);
       //setLED(0,250,0);


       // done
       */

       // Convert
       int upPos = 100;
       int newPos = 90;
       if(command.equals("up"))
       {
         newPos = upPos;
         Serial.println("going up");
         //Serial.print(newPos );
       }
       else if(command.equals("down"))
       {
         newPos = 10; //test these
         Serial.println("going down");

       }
       else{
          newPos = command.toInt();
       }



            // Make sure it is in the right range
      // And set the position
      servoPos = constrain( newPos, 0 , 180);

      // Set the servo
      myServo.write( servoPos );
    //Serial.println("wazzup" );
      Serial.print(newPos );

      //BLINK IT
      blinkLED(100, 100, 120);
      delay(3000);
      //blinkLED(230, 230);



       return 1;
    }

    //function for controlling individual LEDs
    int blinkLEDIndividualLEDs(int g, int b)
    {

      //red = r;
      green = g;
      blue = b;
      // write the mixed color
      int delayTime = 1000;
      int totalTime = 10000;
      int numberBlinks = totalTime/delayTime;

      int blank = 0;

      for(int i = 0; i < numberBlinks; i++){
        //analogWrite( redPin, red);
        analogWrite( greenPin, green);
        analogWrite( bluePin, blue);
        delay(delayTime);

        //analogWrite( redPin, blank);
        analogWrite( greenPin, blank);
        analogWrite( bluePin, blank);
        delay(delayTime);
      }

      return 1;
    }

    //function for controlling RGB LED
    int blinkLED(int r, int g, int b)
    {

      red = r;
      green = g;
      blue = b;
      // write the mixed color
      int delayTime = 1000;
      int totalTime = 10000;
      int numberBlinks = totalTime/delayTime;

      int blank = 0;

      for(int i = 0; i < numberBlinks; i++){
        analogWrite( redPin, red);
        analogWrite( greenPin, green);
        analogWrite( bluePin, blue);
        delay(delayTime);

        analogWrite( redPin, blank);
        analogWrite( greenPin, blank);
        analogWrite( bluePin, blank);
        delay(delayTime);
      }

      return 1;
    }

    int setLED(int r, int g, int b)
    {

      red = r;
      green = g;
      blue = b;
      analogWrite( redPin, red);
      analogWrite( greenPin, green);
      analogWrite( bluePin, blue);


      return 1;
    }
Click to Expand
0

Code including LED integration - again, the LEDs will work & follow the command structure, but when this happens the motor travels only in one direction & gets stuck.

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

49313 Designing for the Internet of Things (Undergrad)

· 22 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Focused on
Skills
About

What if we could use connected devices to make the restroom experience less hazardous?