Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Adafruit_CharLCD as LCD
- import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
- from time import sleep
- #Some code i use in my other python file to use the screen, found on a website
- # Raspberry Pi pin setup
- rs = 25
- en = 24
- d4 = 23
- d5 = 17
- d6 = 18
- d7 = 22
- backlight = 2
- #buttonPin=26
- # Define LCD column and row size for 16x2 LCD.
- columns = 8
- rows = 1
- GPIO.setmode(GPIO.BCM)
- lcd = LCD.Adafruit_CharLCD(rs,en,d4,d5,d6, d7,columns,rows,backlight)
- ####test##
- GPIO.setmode(GPIO.BCM) #This is here twice, might remove one later
- ## Code from raspberrypihq.com modified by Kelson
- def button_callback(channel):
- #print("Button was pushed!")
- #Modified code prints "Hello!" in a scrolling fashion.. H clear e clear.. so on.
- lcd.message("H")
- lcd.clear()
- lcd.message("e")
- lcd.clear()
- lcd.message("l")
- lcd.clear()
- lcd.message("l")
- lcd.clear()
- lcd.message("o")
- lcd.clear()
- lcd.message("!")
- GPIO.setwarnings(False) # Ignore warning for now
- GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 26 to be an input pin and set initial value to be pulled low (off)
- GPIO.add_event_detect(26,GPIO.RISING,callback=button_callback) # Setup event on pin 10 rising edge
- message = input("Press enter to quit\n\n") # Run until someone presses enter
- GPIO.cleanup() # Clean up
- #lcd.clear() #unused code
Add Comment
Please, Sign In to add comment