110 lines
1.9 KiB
Plaintext
110 lines
1.9 KiB
Plaintext
|
|
||
|
#include <Servo.h>
|
||
|
|
||
|
Servo myservo; // create servo object to control a servo
|
||
|
|
||
|
int sensor1Pin = 14; // the number of the pushbutton pin
|
||
|
int sensor2Pin = 15;
|
||
|
|
||
|
int servoPin = 12;
|
||
|
|
||
|
int bomba = 3;
|
||
|
int led_flores = 9;
|
||
|
int flores = 7;
|
||
|
int avion = 5;
|
||
|
int led_avion = 13;
|
||
|
int ventilador = 11;
|
||
|
|
||
|
int sensor1, sensor2;
|
||
|
|
||
|
void setup() {
|
||
|
|
||
|
//pinMode(bomba, OUTPUT); // PWM 3
|
||
|
//pinMode(avion, OUTPUT); // PWM 5
|
||
|
//pinMode(ventilador, OUTPUT); // PWM 11
|
||
|
pinMode(led_flores, OUTPUT);
|
||
|
pinMode(flores, OUTPUT);
|
||
|
pinMode(led_avion, OUTPUT);
|
||
|
pinMode(servoPin, OUTPUT);
|
||
|
digitalWrite(servoPin, 0);
|
||
|
|
||
|
pinMode(sensor1Pin, INPUT);
|
||
|
pinMode(sensor2Pin, INPUT);
|
||
|
|
||
|
digitalWrite(flores, 0);
|
||
|
digitalWrite(led_flores, 0);
|
||
|
digitalWrite(led_avion, 0);
|
||
|
|
||
|
//analogWrite(ventilador, 200);
|
||
|
analogWrite(ventilador, 0);
|
||
|
//analogWrite(bomba, 150);
|
||
|
analogWrite(bomba, 0);
|
||
|
//analogWrite(avion, 99);
|
||
|
analogWrite(avion, 0);
|
||
|
|
||
|
}
|
||
|
|
||
|
void loop(){
|
||
|
|
||
|
sensor1 = digitalRead(sensor1Pin);
|
||
|
sensor2 = digitalRead(sensor2Pin);
|
||
|
|
||
|
// seq1();
|
||
|
// delay(5000);
|
||
|
// seq2();
|
||
|
// delay(5000);
|
||
|
|
||
|
if (sensor1 == HIGH) {
|
||
|
// SEQ1
|
||
|
seq1();
|
||
|
}
|
||
|
else if (sensor2 == HIGH) {
|
||
|
// SEQ2
|
||
|
seq2();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void seq1()
|
||
|
{
|
||
|
myservo.attach(servoPin);
|
||
|
myservo.write(55);
|
||
|
digitalWrite(led_flores, 1);
|
||
|
delay(2500);
|
||
|
analogWrite(bomba, 150);
|
||
|
delay(6000);
|
||
|
digitalWrite(flores, 1);
|
||
|
delay(10000);
|
||
|
myservo.detach();
|
||
|
digitalWrite(led_flores, 0);
|
||
|
analogWrite(bomba, 0);
|
||
|
digitalWrite(flores, 0);
|
||
|
|
||
|
}
|
||
|
|
||
|
void seq2()
|
||
|
{
|
||
|
myservo.attach(servoPin);
|
||
|
myservo.write(55);
|
||
|
digitalWrite(led_avion, 1);
|
||
|
delay(3000);
|
||
|
analogWrite(ventilador, 200);
|
||
|
delay(4000);
|
||
|
analogWrite(avion, 150);
|
||
|
delay(100);
|
||
|
analogWrite(avion, 102);
|
||
|
delay(8000);
|
||
|
myservo.detach();
|
||
|
digitalWrite(led_avion, 0);
|
||
|
analogWrite(ventilador, 0);
|
||
|
analogWrite(avion, 0);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|