#include <Servo.h>
Servo one;
Servo two;
int carwiper = 5;
int door = 3;
int btn1 = 4;
int btn2 = 2;
void setup() {
// put your setup code here, to run once:
one.attach(carwiper);
one.write(0);
two.attach(door);
two.write(0);
Serial.begin(9600);
pinMode(btn1, INPUT);
pinMode(btn2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
bool btn1state = digitalRead(btn1);
bool btn2state = digitalRead(btn2);
if(btn1state == 1){
one.write(180);
Serial.println("Button 1 and carwiper are working");
delay(500);
}
else{
one.write(0);
Serial.println("Button 1 and carwiper aren't active");
delay(500);
}
if(btn2state == 1){
two.write(90);
Serial.println("Button 2 is working and the door is open");
delay(500);
}
else {
two.write(0);
Serial.println("Button 2 isnt working so the door is closed");
delay(500);
}
}