Skip to content

Instantly share code, notes, and snippets.

@salmanfarisvp
Created March 10, 2017 04:50
Show Gist options
  • Save salmanfarisvp/b1c3d55e313cae26b3c336bd22426b67 to your computer and use it in GitHub Desktop.
Save salmanfarisvp/b1c3d55e313cae26b3c336bd22426b67 to your computer and use it in GitHub Desktop.
Smart Electric Waste Bin
#include <Servo.h>
int ir;
Servo myservo;
void setup()
{
ir = A1; //IR Connected to A1
pinMode(ir,INPUT);
Serial.begin(9600); //Buadrate
myservo.attach(9); //Servo Connected to pin 9
}
void loop()
{
int value = analogRead(ir);
Serial.println(value);
if (value >= 50)
{
myservo.write(90);
}
else
{
myservo.write(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment