1. Use pen-pencil-ruler and make a connection on your exercise book among Arduino UNO, I2CLCD, and PushButton (Fig-1).
Figure-1:
2. Check that your physical connection among K1, I2CLCD (I2C bus drievn LCD), and UNO agrees with Fig-1. The Rip (internal pull-resistor) is within the MCU.
4. Connect your UNO with PC using USB cable.
5. Open IDE and observe that the following two blank functions have appeared.
void setup()
{
}
void loop()
{
}
6. The tasks that will be executed only once or for a limited number of times will be put in the setup() function, and these are:
(1) Intialize Serial Port so that some message can be shown on the OutputBox of Serial Monitor.
Serial.begin(9600);
(2) Direction of DPin-4 as input with internal pull-up resistor enaled/connected.
pinMode(4, INPUT_PULLUP)
(3) Initialize I2LCD so that some message can be shown on it.
lcd.begin();
or
lcd.init();
(4) Place the following line (called header file) at the top of setup() function. This file contains the meanings of various symbolic names and codes for the functions like licd.begin().
#include<LiquidCrystal_I2C.h>
(5) Place the following line (called creation of lcd object) underneath the line of Step-(4).
LiquidCrystal_I2C lcd(0x27, 16, 2); //if does not work, then chnage 0x27 to 0x3F
(6) Check again and again that K1 is closed and then show the message Hello on the Top Line of LCD.
while digitalRead(4) != LOW)
{
; //check and wait until K1 is closed
}
lcd.setCursor(7, 0); // set cursor at the middle of Top Line
lcd.print("Hello") //show message on LCD
7. The tasks that will be executed again and again will be put in the loop() function.
(1) After showing Hello message on the LCD, keep blinking the onboard LED (L) of the Arduino UNO Board at 1-sec interval. (put this code: pinMode(13, OUTPUT); in the setup() function.)
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);