0% found this document useful (0 votes)
3 views3 pages

Program Code

The document contains program code for a smart dustbin that differentiates between dry and wet waste using a servo motor and ultrasonic sensor. It utilizes an LCD display to show the status of the bin and includes various output indicators for different waste levels. The code also incorporates an infrared sensor and a button for user interaction and control.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Program Code

The document contains program code for a smart dustbin that differentiates between dry and wet waste using a servo motor and ultrasonic sensor. It utilizes an LCD display to show the status of the bin and includes various output indicators for different waste levels. The code also incorporates an infrared sensor and a button for user interaction and control.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program code for the dustbin dry and wet waste

#include<Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
/****/
#define trigpin 13
#define echopin 12
/****/
Servo myservo;
int pos=0;
int button=2;
/****/
LiquidCrystal_I2C lcd(0x20,16,2);
/****/
int w=3;
int y=4;
int g=5;
int r=6;
/***/
char message;
/****/
int ir=7;
/****/

/****/
void setup()
{
[Link](9600);
[Link](9);
/****/
pinMode(trigpin,OUTPUT);
pinMode(echopin,INPUT);
/****/
pinMode(ir,INPUT);
/****/
pinMode(w,OUTPUT);
pinMode(y,OUTPUT);
pinMode(g,OUTPUT);
pinMode(r,OUTPUT);
digitalWrite(w,LOW);
digitalWrite(y,LOW);
digitalWrite(g,LOW);
digitalWrite(r,LOW);
/***/
pinMode(button,INPUT);
/****/
[Link]();
[Link]();
[Link]();
[Link](2,0);
delay(15);
[Link]("smart dustbin");
delay(500);
[Link]();
}
void loop()
{
int irs,b;
b=digitalRead(button);
irs=digitalRead(ir);
/****/
[Link](2,0);
/***/
long duration,distance;
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
digitalWrite(trigpin,LOW);
duration=pulseIn(echopin,HIGH);
distance=(duration/2)/29.1;
/****/
//[Link]("Distance: ");
//[Link](distance);
/****/
if(irs==1&&b==1)
{

[Link](pos=90);
delay(100);
}
else
{
[Link](pos=0);
delay(100);
}

if(distance>=750)
{
digitalWrite(w,HIGH);
digitalWrite(y,LOW);
digitalWrite(g,LOW);
digitalWrite(r,LOW);

}
if(distance<750&&distance>500)
{
digitalWrite(w,LOW);
digitalWrite(y,HIGH);
digitalWrite(g,LOW);
digitalWrite(r,LOW);
}
if(distance<500&&distance>250)
{
digitalWrite(g,HIGH);
digitalWrite(y,LOW);
digitalWrite(w,LOW);
digitalWrite(r,LOW);
}
if(distance<=250)
{
digitalWrite(r,HIGH);
digitalWrite(y,LOW);
digitalWrite(g,LOW);
digitalWrite(w,LOW);
[Link]("bin full(dry)");
delay(20);
}
else
{
[Link]();
}
if([Link]())
{
message=[Link]();
if(message=='1')
{
[Link](1,0);
[Link]("bin full(wet)");
delay(20);
}
else if(message=='0')
{
[Link]();
}
else
{
[Link]();
}
}

You might also like