Nimit PatelLeandro MongelluzzoRyan Scibetta
Published © GPL3+

The Screaming Trash Can

Ever felt unmotivated to take out the trash? Well now it screams until you do. Why? Well why not?

Beginner1 hour373
The Screaming Trash Can

Things used in this project

Hardware components

Argon
Particle Argon
×3
LED (generic)
LED (generic)
×3
Buzzer
Buzzer
×2
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
IFTTT Applet

Story

Read more

Schematics

Schematic for Trash Headquarters

This is the schematic for the Trash Headquarters that flashes if a Trashcan is full.

Schematics for Trash Sensor Setup

This is the schematic for creating the sensor that looks into the trash can

Code

Trash Can Sensor Code 1

Arduino
This is the code used for the sensors that detect the trash level of the first trash can
// This #include statement was automatically added by the Particle IDE.
#include <HC_SR04.h> //Used to set up the library for the ultrasonic sensor

double cm = 0.0;
bool beam_status = false;

int trigPin = D4; //Setting up the pin that sends out signals on the Ultrasonic sensor
int echoPin = D5; //Setting up the pin that receives out signals on the Ultrasonic sensor
int ledPin = D7; //Setting up the pin for the LED indication
int buzzPin = D2; //Setting up the signal pin for the buzzer


HC_SR04 rangefinder = HC_SR04(trigPin, echoPin); //Enabling the ultrasonic sensor

void setup() 
{
    Spark.variable("cm", &cm, DOUBLE);
    pinMode(ledPin,OUTPUT);
    pinMode(buzzPin,OUTPUT);
    Particle.subscribe("warningRyanTrash", myHandler); //Subscribes to the event being published by the headquarters
}

void loop() 
{
    cm = rangefinder.getDistanceCM(); //This is initializing the sensor to look for distances in cm
    if (cm<15){
        if (beam_status==false){
            Particle.publish("trashLevelRyan", "too_high"); //If something is closer than 15 cm of the sensor, the Argon will publish this event to the cloud once
            beam_status = true;   
        }
    } else {
        if (beam_status==false){
            
        } else {
            Particle.publish("trashLevelRyan", "all_clear"); //When the object leaves the 15 cm zone, the Argon will publish this event to the cloud once
            beam_status = false;
        }
    }
    delay(500);
}

void myHandler(const char *event, const char *data)
{    
    digitalWrite(ledPin,HIGH);
     if (strcmp(data,"full")==0) {      //If the event "warningNimitTrash" being published from the headquarters says "full", this loop is excuted
        digitalWrite(ledPin,HIGH);      //Turn on LED
        analogWrite(buzzPin,130);       //Turn on buzzer
    }
    else if (strcmp(data,"clean")==0) { //If the event "warningNimitTrash" being published from the headquarters says "clean", this loop is excuted
        digitalWrite(ledPin,LOW);       //Turn off LED
        analogWrite(buzzPin,0);         //Turn off buzzer
    }
}

Trash Can Sensor Code 2

Arduino
This is the code used for the sensors that detect the trash level of the second trash can
// This #include statement was automatically added by the Particle IDE.
#include <HC_SR04.h> //Used to set up the library for the ultrasonic sensor


double cm = 0.0;
bool beam_status = false;

int trigPin = D4; //Setting up the pin that sends out signals on the Ultrasonic sensor
int echoPin = D5; //Setting up the pin that receives out signals on the Ultrasonic sensor
int ledPin = A5; //Setting up the pin for the LED indication
int buzzPin = D2; //Setting up the signal pin for the buzzer


HC_SR04 rangefinder = HC_SR04(trigPin, echoPin); //Enabling the ultrasonic sensor

void setup() 
{
    Spark.variable("cm", &cm, DOUBLE); 
    pinMode(ledPin,OUTPUT); 
    pinMode(buzzPin,OUTPUT);
    Particle.subscribe("warningNimitTrash", myHandler); //Subscribes to the event being published by the headquarters
}

void loop() 
{
    cm = rangefinder.getDistanceCM(); //This is initializing the sensor to look for distances in cm
    if (cm<15){                       
        if (beam_status==false){
            Particle.publish("trashLevelNimit", "too_high"); //If something is closer than 15 cm of the sensor, the Argon will publish this event to the cloud once
            beam_status = true;   
        }
    } else {
        if (beam_status==false){
            
        } else {
            Particle.publish("trashLevelNimit", "all_clear"); //When the object leaves the 15 cm zone, the Argon will publish this event to the cloud once
            beam_status = false;
        }
    }
    delay(500);
}

void myHandler(const char *event, const char *data)
{    
    if (strcmp(data,"full")==0) {       //If the event "warningNimitTrash" being published from the headquarters says "full", this loop is excuted
        digitalWrite(ledPin,HIGH);      //Turn on LED
        analogWrite(buzzPin,130);       //Turn on buzzer
    }
    else if (strcmp(data,"clean")==0) { //If the event "warningNimitTrash" being published from the headquarters says "clean", this loop is excuted
        digitalWrite(ledPin,LOW);       //Turn off LED
        analogWrite(buzzPin,0);         //Turn off buzzer
    }
}

Headquarters Code

Arduino
This is the code used for creating the trash hub - the device that will sense the trash levels and create a response based on that.
int led_pin1 = D7; //Sets up the pin first LED (on board the Argon)
int led_pin2 = A0; //Sets up the pin for second LED


void setup() {
  pinMode(led_pin1,OUTPUT); 
  pinMode(led_pin2,OUTPUT);
  Particle.subscribe("trashLevelNimit", myHandler1); //Subscribes to the sensor detecting the trash in first location
  Particle.subscribe("trashLevelRyan", myHandler2); //Subscribes to the sensor detecting the trash in second location
}


void loop() {

}


void myHandler1(const char *event, const char *data)
{
    if (strcmp(data,"too_high")==0) { //Compares incoming data from the event "trashLevelNimit" to the characters "too_high". If they match, then it excutes this loop
        digitalWrite(led_pin1,HIGH); //Turns on LED
        Particle.publish("warningNimitTrash","full"); //Publishes an event that that says "full" which is recieved by the trash can sensor subscribed to it
    }
    else if (strcmp(data,"all_clear")==0) { //Compares incoming data from the event "trashLevelNimit" to the characters "all_clear". If they match, then it excutes this loop
        digitalWrite(led_pin1,LOW); //Turns off LED
        Particle.publish("warningNimitTrash","clean"); //Publishes an event that that says "clean" which is recieved by the trash can sensor subscribed to it
    }
}

void myHandler2(const char *event, const char *data)
{
    if (strcmp(data,"too_high")==0) { //Compares incoming data from the event "trashLevelNimit" to the characters "too_high". If they match, then it excutes this loop
        digitalWrite(led_pin2,HIGH); //Turns on LED
        Particle.publish("warningRyanTrash","full"); //Publishes an event that that says "full" which is recieved by the trash can sensor subscribed to it
    }
    else if (strcmp(data,"all_clear")==0) { //Compares incoming data from the event "trashLevelNimit" to the characters "all_clear". If they match, then it excutes this loop
        digitalWrite(led_pin2,LOW); //Turns off LED
        Particle.publish("warningRyanTrash","clean"); //Publishes an event that that says "clean" which is recieved by the trash can sensor subscribed to it
    }
}

Credits

Nimit Patel

Nimit Patel

1 project • 2 followers
Leandro Mongelluzzo

Leandro Mongelluzzo

1 project • 2 followers
Ryan Scibetta

Ryan Scibetta

1 project • 2 followers
Thanks to Joshua Hrisko.

Comments

Add projectSign up / Login