-
-
Save salmanfarisvp/b1c3d55e313cae26b3c336bd22426b67 to your computer and use it in GitHub Desktop.
Smart Electric Waste Bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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