Mahmoud Ahmed
Published © CC BY-NC-SA

Automated Clothes & Shoes Donation Machine

The machine will sense if you donated with something and will ask you if you want to share your photo on the machine's twitter account

IntermediateFull instructions provided3,018
Automated Clothes & Shoes Donation Machine

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
1Sheeld
1Sheeld
×1
Power Supply 12V/ 5A
×1
Fan 12V
×1
LED strips
×1
Push Button
×1
Android Smartphone
×1
Relay Module 5V
×1

Software apps and online services

Twitter
Twitter

Story

Read more

Custom parts and enclosures

I7san.zip

Schematics

Donation Machine Fritizing File

Code

Donation Machine Code

Plain text
///////////////////////////////////////////////////////////////////////////
//                                                                       //
//                    Developed by : Eng. Mahmoud Tolba                  //
//                       Last modify : 26 / 5 / 2015                     //  
//                                                                       //
///////////////////////////////////////////////////////////////////////////

#define CUSTOM_SETTINGS
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_SMS_SHIELD
#define INCLUDE_TWITTER_SHIELD
#define INCLUDE_CAMERA_SHIELD
#define INCLUDE_TEXT_TO_SPEECH_SHIELD

// Include 1Sheeld library.
#include <OneSheeld.h>

const int trigPin1 = 2;
const int echoPin1 = 3;

const int trigPin2 = 7;
const int echoPin2 = 8;

// Define a boolean flag.
boolean isMessageSent = false;

const int buttonPin = 12;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

const int ledPin = 13;       // the number of the led pin


//--------------------------------------------------------------------------------------

void setup() {
  // Start communication
  OneSheeld.begin();

  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);

  pinMode(echoPin2, INPUT);
  pinMode(trigPin2, OUTPUT);

}

void loop()
{
  long duration1, distance1, duration2, distance2;

  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);

  duration1 = pulseIn(echoPin1, HIGH);
  // convert the time into a distance1
  distance1 = duration1 / 29 / 2;

  digitalWrite(trigPin2, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin2, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin2, LOW);

  duration2 = pulseIn(echoPin2, HIGH);
  distance2 = duration2 / 29 / 2;

  Terminal.print("Ultrasonic1 = ");
  Terminal.print(distance1);
  Terminal.println(" cm");

  Terminal.print("Ultrasonic2 = ");
  Terminal.print(distance2);
  Terminal.println(" cm");

  // Ultrasonic sensor measeures the depth of the machine if this distance1 increased above 100 cm this means that the door is opened
  // The machine will tell the user to stand in front of the camera then the machine will take a photo for him and uplaoad it on twitter

  if (distance1 < 40) {

    // ------------------------- Chack if the machine is filled --------------------------------
    if (distance1 <= 60 && distance2 <= 60) {
      if (!isMessageSent)
      {
        // Send the SMS.

        SMS.send("+201222326539  ", "         ");

        Terminal.println("Sending SMS done");

        Terminal.println("Machine is filled");

        // Set the flag.
        isMessageSent = true;
      }
    }// if machine is filled

    else
    {
      // Reset the flag
      isMessageSent = false;

      Terminal.println("Some one donated with something");

      // Wait for 5 seconds while the user stand in front of the camera
      TextToSpeech.say("Please stand in front of the camera After Your donation");
      OneSheeld.delay(5500);
      TextToSpeech.say("If you want to share you photo with community please long press the Bush button");
      OneSheeld.delay(7500);

      // read the state of the pushbutton value:
      buttonState = digitalRead(buttonPin);

      if (buttonState == HIGH) {

        TextToSpeech.say("You have pressed the push button Please stand behind the red line");
        OneSheeld.delay(6000);

        Terminal.println("Bush Button is pressed");

        for (int i = 1; i <= 3; i++) {
          digitalWrite(ledPin, HIGH);             // turn the LED on (HIGH is the voltage level)
          OneSheeld.delay(1000);                  // wait for a second
          digitalWrite(ledPin, LOW);              // turn the LED off by making the voltage LOW
          OneSheeld.delay(1000);                  // wait for a second
        }//for

        Camera.setFlash(ON);
        // Take the picture.
        Camera.rearCapture();

        Terminal.println("Photo taken");
        
        OneSheeld.delay(3000);
        TextToSpeech.say("Yor photo has been taken");
        OneSheeld.delay(7000);

        // Post the picture on Twitter.
        Twitter.tweetLastPicture("               ");

        Terminal.println("Uploading");

        TextToSpeech.say("Uploading your image");
        OneSheeld.delay(4000);
        TextToSpeech.say("Thank you");

        // Wait for 5 seconds.
        OneSheeld.delay(5000);

      }// if button si pressed
      else {
        TextToSpeech.say("You didn't press the push button, Thank you sir");
        OneSheeld.delay(6000);
      }//Push button isn't pressed
    }//Machine wasn't filled 

  }// if distance1 < 40 cm
}//void loop

Credits

Mahmoud Ahmed

Mahmoud Ahmed

6 projects • 39 followers
Building new products is my favourite hobby :D

Comments