Code for smart trash bin

const int buttonPin = A0;
#include <Servo.h>
Servo myservo1; 
Servo myservo2;     
int buttonState = 0;

void setup() {
  myservo1.attach(A1);
  myservo2.attach(A4);
  pinMode(buttonPin, INPUT);
}

void loop() {

  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
     myservo1.write(0); 
     myservo2.write(180);
  } else {
     myservo1.write(60); 
     myservo2.write(120);
     delay(3000);
  }
}

Comments