#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD. Set the LCD address and the dimensions (16 characters and 2 lines)
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
#define LED_PIN 2 // Define the pin the LED is connected to
void setup() {
Serial.begin(115200);
LCD.init(); // Initialize the LCD
LCD.backlight(); // Turn on the backlight
pinMode(LED_PIN, OUTPUT); // Set the LED pin as an output
pinMode(16, INPUT_PULLUP); // Set the button pin as an input with pull-up resistor
LCD.setCursor(0, 0);
LCD.print("MY NAME IS ");
LCD.setCursor(0, 1);
LCD.print("AINA FAQIHAH");
}
void loop() {
int button_state = digitalRead(16); // Read the state of the button
Serial.print("Button State: ");
Serial.println(button_state);
if (button_state == LOW) {
// If the button is pressed, blink the LED
digitalWrite(LED_PIN, HIGH); // Turn on the LED
delay(250); // Wait for 250 milliseconds
digitalWrite(LED_PIN, LOW); // Turn off the LED
delay(250); // Wait for 250 milliseconds
} else {
// If the button is not pressed, turn off the LED
digitalWrite(LED_PIN, LOW);
}
}