SMART ECO BIN (GIVES YOU CHOCOLATE IF YOU DEPOSITE WASTE BOTTLE )

working
IT AUTOMATICALLY DETECTS BOTTLES WITH HELP OF  LASER & LDR .THEN DOOR OPENS AND BOTTLES GOES TO INNER CRUSHER MOTOR SIDE AND THEN DOOR CLOSES.A HIGH POWER CRUSHER MOTOR OF 500W USED FOR CRUSHING.THEN ONE CHOCLATE COMES OUT.(SERVO MOTOR USED FOR THIS.)


inside view

MOTOR AND BLADE



CHOCLATE PIPE WITH SERVO MOTOR













MOTOR COVERING

OPENING DOOR USING CD TRAY

CIRCUIT

#define ldr_1 A5
#define ldr_2 A4
#define ldr_1_upper_threshold 600
#define ldr_2_upper_threshold 600
#define ldr_1_lower_threshold 50
#define ldr_2_lower_threshold 150
#define servo1 8
#define left11 A2
#define left12 A3
#define motor_open_sensor 9
#define motor_close_sensor 10
#define relay A0
#define led 3
int ldr_1_voltage, ldr_2_voltage;
#include <Servo.h>
Servo myservo1;
void setup()
{ pinMode(relay, OUTPUT);
  pinMode(led, OUTPUT);
  crusher_on(); crusher_off();
  serial_init();
  sensor_init();
  myservo1.attach(servo1);
  motorinit();
  delay(500);
  // door_open();
  door_close();
  stop1(); servo_pull();
  //servo_push();
}

void loop()
{
  bottle_detect();
  door_open(); delay(3000); stop1();
  door_close(); delay(1000); stop1();
  crusher_on(); crusher_off(); delay(1000);
  servo_push();//delay(1000);
  servo_pull();
  led_blink();led_blink();led_blink();
  led_blink();led_blink();led_blink();
}
void bottle_detect(void)
{
  do
  {
    ldr_1_voltage = analogRead(ldr_1);
    Serial.print("ldr_1_voltage="); Serial.println(ldr_1_voltage);
    ldr_2_voltage = analogRead(ldr_2);
    Serial.print("ldr_2_voltage="); Serial.println(ldr_2_voltage);
  } while (!(ldr_1_upper_threshold > ldr_1_voltage && ldr_2_upper_threshold > ldr_2_voltage && ldr_1_lower_threshold < ldr_1_voltage && ldr_2_lower_threshold < ldr_2_voltage));
  Serial.println("bottle found");
  delay(2000);
}
void led_blink(void)
{
  digitalWrite(led, HIGH);  delay(300);
  digitalWrite(led, LOW);  delay(300);
}
void crusher_on(void)
{
  digitalWrite(relay, HIGH);  delay(2000);
}
void crusher_off(void)
{
  digitalWrite(relay, LOW);
}
void servo_pull(void)
{
  myservo1.write(90); //90 DEGREE
  servo_delay();
}
void servo_push(void)
{
  myservo1.write(30); //90 DEGREE
  servo_delay();
}
void servo_delay(void)
{
  delay(1000);
}

void door_open(void)
{
  do
  {
    digitalWrite(left11, HIGH); digitalWrite(left12, LOW);
  }
  while (digitalRead(motor_open_sensor));
  stop1();
}
void door_close(void)
{
  do
  {
    digitalWrite(left11, LOW); digitalWrite(left12, HIGH);
  }
  while (digitalRead(motor_close_sensor));
  stop1();
}
void stop1(void)
{
  digitalWrite(left11, LOW); digitalWrite(left12, LOW);
}
void sensor_init(void)
{
  pinMode(motor_open_sensor, INPUT_PULLUP);
  pinMode(motor_close_sensor, INPUT_PULLUP);
  pinMode(ldr_1, INPUT_PULLUP);
  pinMode(ldr_2, INPUT_PULLUP);
}
void serial_init(void)
{
  Serial.begin(9600); Serial.println("haiu");
}


void motorinit(void)
{
  pinMode(left11, OUTPUT);  pinMode(left12, OUTPUT);
}