Lesson 6: LCD display

Objective

Using Grove - 16x2 LCD display to display "Hello World" message.

Hardware requirements

Prepare:

  • MicroUSB cable
  • Raspberry Pi 3 Model B
  • Computer

Set contents

  • Grove Base Hat
  • Grove wire
  • Grove - LCD display 16*2

Connecting equipment

Step 1 Connect Grove - 16*2 LCD display to I2C port on Base Hat.

Step 2 Connect Base Hat to Raspberry Pi.

Step 3 Connect Raspberry Pi to the power supply using a micro USB cable.

Software

Note

Make sure you clone the python.py repository library on your Raspberry Pi.

Step 1: Enter the following commands to open the python file

  1. cd grove.py
  2. nano lesson_6.py

Step 2: Copy the following code

  1. #!/usr/bin/env python
  2.  
  3. import time
  4.  
  5. from grove.display.jhd1802 import JHD1802
  6.  
  7. def main():
  8. # Grove - 16x2 LCD(White on Blue) connected to I2C port
  9. lcd = JHD1802()
  10.  
  11. lcd.setCursor(0, 0)
  12. lcd.write('hello, world!!!')
  13.  
  14. print('application exiting...')
  15.  
  16. if __name__ === '__main__':
  17. main()

Step 3:Włączprogram

  1. sudo chmod +x lesson_6.py
  2. sudo ./lesson_6.py

You should see "hello, world!" on the LCD.

If you want to use Grove - LCD 16*2 to display other symbols, just change lcd.write( 'hello, world!!!') in the code.

Table of contents

Botland.store - shop for makers!