Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart Dustbin using arduino #30

Open
adarshsharma2003 opened this issue Aug 10, 2024 · 1 comment
Open

Smart Dustbin using arduino #30

adarshsharma2003 opened this issue Aug 10, 2024 · 1 comment

Comments

@adarshsharma2003
Copy link

Smart bins are equipped with sensors that can detect the fill level of the bin. This information is often transmitted wirelessly over WiFI or Bluetooth, allowing waste management teams to optimize collection routes and reduce unnecessary pickups.

@adarshsharma2003
Copy link
Author

``#include <Servo.h>

Servo servoMain; // Define our Servo

int trigpin = 10;

int echopin = 11;

int distance;

float duration;

float cm;

void setup()

{

servoMain.attach(9); // servo on digital pin 10

pinMode(trigpin, OUTPUT);

pinMode(echopin, INPUT);

}

void loop()

{

digitalWrite(trigpin, LOW);

delay(2);

digitalWrite(trigpin, HIGH);

delayMicroseconds(10);

digitalWrite(trigpin, LOW);

duration = pulseIn(echopin, HIGH);

cm = (duration/58.82);

distance = cm;

if(distance<30)

{

servoMain.write(180); // Turn Servo back to center position (90 degrees)

delay(3000);

}

else{

servoMain.write(0);

delay(50);

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant