// LIBRERÍAS
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
// Instancias
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo servo_9;
// Botones
const int boton1 = 2;
const int boton2 = 3;
const int boton3 = 4;
const int buzzer = 5;
// Led
const int led = 8;
void setup(){
servo_9.attach(9);
pinMode(boton1, INPUT_PULLUP);
pinMode(boton2, INPUT_PULLUP);
pinMode(boton3, INPUT_PULLUP);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.init();
lcd.backlight();
digitalWrite(led, LOW);
lcd.print("Bienvenido");
}
void loop(){
int estadoBoton1 = digitalRead(boton1);
int estadoBoton2 = digitalRead(boton2);
int estadoBoton3 = digitalRead(boton3);
if (estadoBoton1 == LOW) {
lcd.clear();
lcd.print("LED ENCENDIDO");
digitalWrite(led, HIGH);
delay(3000);
lcd.clear();
lcd.print("LED APAGADO");
digitalWrite(led, LOW);
delay(1500);
lcd.clear();
}
if (estadoBoton2 == LOW) {
lcd.clear();
lcd.print("SERVO EN");
lcd.setCursor(0, 1);
lcd.print("MOVIMIENTO");
servo_9.write(180);
delay(3000);
lcd.clear();
lcd.print("SERVO EN");
lcd.setCursor(0, 1);
lcd.print("REPOSO");
delay(1500);
lcd.clear();
}
if (estadoBoton3 == LOW) {
lcd.clear();
lcd.print("BUZZER ENCENDIDO");
digitalWrite(buzzer, HIGH);
delay(2000);
lcd.clear();
lcd.print("BUZZER APAGADO");
digitalWrite(buzzer, LOW);
delay(1500);
lcd.clear();
}
}1
2
3