Skip to main content

Posts

Showing posts from June, 2018

raspberry pi 3 lcd working code

# The wiring for the LCD is as follows: # 1 : GND # 2 : 5V # 3 : Contrast (0-5V)* # 4 : RS (Register Select) # 5 : R/W (Read Write)       - GROUND THIS PIN # 6 : Enable or Strobe # 7 : Data Bit 0             - NOT USED # 8 : Data Bit 1             - NOT USED # 9 : Data Bit 2             - NOT USED # 10: Data Bit 3             - NOT USED # 11: Data Bit 4 # 12: Data Bit 5 # 13: Data Bit 6 # 14: Data Bit 7 # 15: LCD Backlight +5V** # 16: LCD Backlight GND #import import RPi.GPIO as GPIO import time # Define GPIO to LCD mapping LCD_RS = 7 LCD_E  = 8 LCD_D4 = 25 LCD_D5 = 24 LCD_D6 = 23 LCD_D7 = 18 # Define some device constants LCD_WIDTH = 16    # Maximum characters per line LCD_CHR = True LCD_CMD = False LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line # Timing constants E_PULSE = 0.0005 E_DELAY = 0.0005 def main():   # Main program block   GPIO.setwarnings(False)   GPIO.setmode(GPIO.BCM