///////////////////////////////////// //////////// Code in C++ //////////// ///////////////////////////////////// #include // Library to use I²C communication #include // Library to use the I²C LCD screen LiquidCrystal_I2C lcd(0x27, 16, 2); // Function to name and give the parameters of the I²C LCD screen int led = 2; // Pin of the led int button = 3; // Pin of the button int buttonValue; // Value of the button void setup() { lcd.init(); // Initialization of the I²C LCD screen lcd.backlight(); // To enable the backlight of the I²C LCD screen lcd.setCursor(0, 0); // First line of the I²C LCD screen lcd.print("LED STATUS"); // Message of the first line of the I²C LCD screen pinMode(led, OUTPUT); // The led is configured as an OUTPUT pinMode(button, INPUT); // The button is configured as an INPUT } void loop() { buttonValue = digitalRead(button); //Reading of the value of the button if (buttonValue == 1) { // If the button is ON digitalWrite(led, HIGH); // The led turns ON lcd.setCursor(0, 1); // Second line of the I²C LCD screen lcd.print(" ON"); // Message to display to the I²C LCD screen } else { // If the button is OFF digitalWrite(led, LOW); // The led turns OFF lcd.setCursor(0, 1); lcd.print(" OFF"); } }