# from machine import Pin, I2C: Imports the Pin and I2C classes from the machine module,
# which are used to control the GPIO pins and
# I2C communication on the microcontroller. I2C i.e. IIC stands for inter - IC
# from time import sleep: Imports the sleep function from the time module,
# which is used to pause the program for a specified number of seconds.
# from pico_i2c_lcd import I2cLcd: Imports the I2cLcd class from the pico_i2c_lcd module,
# which is used to control an LCD display via I2C.
# modules
from machine import Pin, I2C
from time import sleep
from pico_i2c_lcd import I2cLcd
i2c=I2C(0,sda=Pin(0), scl=Pin(1), freq=400000)
# Initializes the I2C interface on the microcontroller. It uses I2C bus 0,
# with the SDA (data) line connected to GPIO pin 0 and the SCL (clock) line connected to GPIO pin 1.
# The communication frequency is set to 400 kHz.
I2C_ADDR=i2c.scan()[0]
# Scans the I2C bus for connected devices and retrieves the address of the first device found.
# This address is stored in the I2C_ADDR variable.
#create instance for LCD
lcd=I2cLcd(i2c,I2C_ADDR,2,16)
#LOOP
while True:
lcd.putstr("Hello Students")
sleep(5)
lcd.clear()
# while True:: Starts an infinite loop.
# lcd.putstr("Hello Students"): Displays the string “Hello Students" on the LCD.
# sleep(5): Pauses the program for 5 seconds.
# lcd.clear(): Clears the display on the LCD.