#include <Servo.h>
Servo servoMotor;
int PIR_1 = 2;
int Buzzer = 3;
int LED = 4;
void setup()
{
pinMode(PIR_1, INPUT);
pinMode(PIR_1, INPUT);
pinMode(Buzzer, OUTPUT);
pinMode(LED, OUTPUT);
servoMotor.attach(11);
Serial.begin(9600);
}
void loop()
{
if(digitalRead(PIR_1) == HIGH)
{
digitalWrite(LED, HIGH);
digitalWrite(Buzzer, HIGH);
servoMotor.write(90);
delay(1000); //falta medir el tiempo
Serial.println("¡Tren Aproximandose!");
}
else
{
digitalWrite(PIR_1, LOW);
digitalWrite(Buzzer, LOW);
Serial.println("¡Libre al Paso!");
servoMotor.write(0);
}
}